top of page
Search

#2: Controlling LED light using pushbutton

  • karlalopezsanchez
  • Jan 7, 2021
  • 1 min read

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:



 
 
 

Comentários


bottom of page