Exp 1 (ii)
Exp 1 (ii)
Aim: To interface Push button with Arduino and write a program to ‘turn ON’ LED when
push button is pressed.
Component Required:
Sl No Components Quantity
1 ARDUINO UNO BOARD 1
2 LED 1
3 USB cable for ARDUINO 1
4 Connecting wires --
5 Push Button 1
6 Bread Board 1
7 Resistance 220ohm and 1Kohm 1
Circuit Connection:
#define LED_PIN 8
#define BUTTON_PIN 7
void setup()
{
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT);
void loop()
{
if (digitalRead (BUTTON_PIN)==HIGH)
{
digitalWrite(LED_PIN, HIGH);
}
else
{
digitalWrite(LED_PIN, LOW);
Result: LED will be ON when push button is pressed and LED will be OFF when button is
released.