MisterBotBreak
Published

How to Use Push Button with LED

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

BeginnerProtip1 hour6,763
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

48 projects • 149 followers
I love electronics and cats :D !

Comments