Search This Blog

Friday, 20 January 2017

Arduino Push Button on and off

PROGRAMMED PUSH BUTTON TO CONTROL BOTH ON/OFF USING ARDUINO [V2]

Hello friends,

  This is the second version of project which we already posted using PLC controller. We know that in some application single push button is used for both ON/OFF.  For example in TV to Power ON/OFF, a single push button is used.
Some times, due to the presence of lot number of switches in control panel more chances are there to complicate to find ON or OFF switch. Alternatively, Using this type of switch can reduce the number of switches and hence saves  space making it more integrated. For the purpose of ON and OFF, two inputs are required but in this method it can achieved by using a single switch.
The circuit used in the project is controlled by arduino.

Connection:


The main circuit is shown above. The PUSH Button is connected to Pin No 8 of arduino and VCC. Pull up resistor is connected to the same pin. It means Pin No 8 is Normally LOW. Motor and Arduino are electrically isolated by a Relay. Relay is connected to Pin No. 7. Diode D2 is a freewheeling Diode connected across the Relay coil. To indicate ON, LED is connected Pin 9 in series with a Resistor. Motor should connected to NO (Normally Open) contact of Relay.

Working :

The Arduino detects the position of switch. Initially if the switch is ON it makes the Relay ON by turning Pin 7 High. At the same time,  the Indicator LED will turn ON. Motor Starts to RUN. If the Button is pressed more than 5 seconds, arduino makes  Relay OFF.  The program should be written such that if switch is Pressed less than 5 seconds, motor should RUN and if the Button is pressed more than 5 seconds, motor should go to OFF condition.

Power Circuit:
 
Components Required:


Codes:
const int s=8; //Push Button connected to pin 8
const int m=7; //Motor/Relay connected to pin 7
const int i=9; //Motor ON/OFF Indicator LED connected to pin 6
int k=0; //variable for to Turn ON the Motor
int j=0; //variable for to Turn OFF the Motor

void setup() {
  pinMode(s, INPUT); //assign s as Input
  pinMode(m, OUTPUT); // assign m as Output
}

void loop() {
 k=digitalRead(s); //read Switch position to k
  if(j == LOW) //check whether j=0 to TURN ON MOTOR program 
  {
        if(k == HIGH) //check whether k=1 to enter TURN ON MOTOR program
    {
      digitalWrite(m, HIGH); // TURN ON the motor
      digitalWrite(i, HIGH); // TURN ON the motor indicator
      delay(3000); //wait for 3sec
      k=0; //make k=0
      j=digitalRead(s);//read Switch position to j
    }
  }
      else     //check whether j=1 to enter TURN OFF MOTOR program
      {
        digitalWrite(m, LOW); // Turn OFF the motor
        digitalWrite(i, LOW); //Turn OFF the Indicator
        j=digitalRead(s); // read switch position & send to j
        delay(1000);//wait 1sec
      }
  }



No comments:

Post a Comment