Objective:
To Control (ON/ OFF) the devices using mechanical switching operation
Components Required
- Arduino Uno
- Push Button
- Buzzer
Connection Diagram
Program
int SwitchPin = 2, ButtonPin= 3, BuzzPin=13, sensorValue ;
void setup()
{
pinMode(ButtonPin, INPUT);
pinMode(BuzzPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
sensorValue = digitalRead(ButtonPin);
if(sensorValue == HIGH)
{
Serial.println(“LED ON”);
digitalWrite(BuzzPin, HIGH);
}
else
{
Serial.println(“Buzzer OFF”);
digitalWrite(BuzzPin, LOW);
}
}
Working
The Push Button is a switch. It has input side and output side. The Push button is connected in the path of the device and the power supply. One end connected to the device and the other end connected to the supply. Whenever the button is pressed the path is closed and current flows and make the device ON. If it is not pressed the path is open, no current flows and make the device OFF
Output
The Buzzer makes Sound (when Push Button Pressed)
The Buzzer is Idle (when Push Button not Pressed)