Simple Push Button test with Arduino Nano





Circuit:-



Code:-
int Button = 2;
int val = 0;     

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);  
  pinMode(Button, INPUT);    
}

void loop(){
  val = digitalRead(Button);  
  if (val == HIGH) {         
    digitalWrite(LED_BUILTIN, LOW);  
  } else {
    digitalWrite(LED_BUILTIN, HIGH);  
  }
}


Demo:-


Comments

Popular Posts