#9Beginner
Led Burning with Push Button (Push)
4.9(107)
167 completed

Push control project that turns on the LED when the button is pressed and turns it off when it is released. Teaches button reading and conditional expression usage with digitalRead.
Video
Circuit Diagram

Source Code
1void setup() {
2 pinMode(13, INPUT);
3 pinMode(7, OUTPUT);
4}
5
6void loop() {
7 if (digitalRead(13) == HIGH) {
8 digitalWrite(7, HIGH);
9 } else {
10 digitalWrite(7, LOW);
11 }
12}