Codes for Two Buttons
int ledPin = 13; // choose the pin for the LED
int redPin = 12;
int inputPin = 2; // choose the input pin (for a pushbutton)
int whitePin = 3;
int val = 0; // variable for reading the pin status
int val2 = 0;
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare pushbutton as input
//for green pin
pinMode(redPin, OUTPUT); // declare LED as output
pinMode(whitePin, INPUT); // declare pushbutton as input
}
void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED OFF
} else {
digitalWrite(ledPin, LOW); // turn LED ON
}
//for red pin
val2 = digitalRead(whitePin); // read input value
if (val2 == HIGH) { // check if the input is HIGH
digitalWrite(redPin, LOW); // turn LED OFF
} else {
digitalWrite(redPin, HIGH); // turn LED ON
}
}
