top of page
Search
karlalopezsanchez

#2: Controlling LED light using pushbutton

Let's turn it up a notch and upgrade project #1 by adding more control!

Things you’ll need:

-LED

-10K resistor

-pushbutton

-Arduino UNO

-Breadboard

-Cables


Code:

const int LED =13;

const int BUTTON=7;

int val=0;


void setup() {

pinMode(LED, OUTPUT);

pinMode(BUTTON,INPUT);

}


void loop(){

val=digitalRead(BUTTON);

if(val==HIGH){

digitalWrite(LED,HIGH);

}

else {

digitalWrite(LED, LOW);

}

}



Schematics:



Video:



2 views0 comments

Comments


bottom of page