MisterBotBreak
Published

How to Use Push Button with LED

This project will help you to activate an LED with a push button.

BeginnerProtip1 hour2,670
How to Use Push Button with LED

Things used in this project

Story

Read more

Schematics

boutton_poussoir_dZ9U15j6KE.fzz

Code

Switch

Arduino
int state; 
int limit = 0;

void setup() {                
  pinMode(2, INPUT); 
  pinMode(12, OUTPUT); 
}


void loop() {
  state = digitalRead(2); 

  if(state==LOW) { 
    limit++;
  }
  if(limit&1) { 
    digitalWrite(12,HIGH);
  }
  else { 
    digitalWrite(12,LOW);
  }
  delay(100); }

Credits

MisterBotBreak

MisterBotBreak

37 projects • 66 followers
I love electronic and I make explanatory project on how to control sensors.

Comments