// Black - ground wire
// Red - Power supply wire
const int Button = 2;
const int LED = 11;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(Button, INPUT);
pinMode(LED, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//Serial.println(digitalRead(Button)); //if high = 1, if low = 0
if (digitalRead(Button) == 1 ){ //you can make it equivalent to 1 or HIGH, they will both yield the same result
digitalWrite(LED, HIGH);
Serial.println(digitalRead(Button));
}
else{
digitalWrite(LED, LOW);
Serial.println(digitalRead(Button));
}
delay(100);
}
//here is code for turning on the LED if the button is pressed