Arduino Turn on Led Using Button

Introduction: Arduino Turn on Led Using Button

const int LED = 9;

const int button=2;

void setup() {

// put your setup code here, to run once:

pinMode(LED,OUTPUT);

pinMode(button,INPUT);

}

void loop() {

// put your main code here, to run repeatedly:

if(digitalRead(button) == HIGH)

{

digitalWrite(LED,HIGH);

}

else{

digitalWrite(LED,LOW);

}

}

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Connections

1. arduino uno,

2. led,

3. button,

4. some jumpers,

5. 10k resistor (optional)

Robotics Contest 2016

Participated in the
Robotics Contest 2016

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    2 Discussions

    0
    wold630
    wold630

    3 years ago

    Good work!

    0
    mehmetsukru
    mehmetsukru

    Reply 3 years ago

    thank you! :)