// constants won't change. They're used here to set pin numbers:
const int boto = 4; // the number of the pushbutton pin
const int led = 2; // the number of the LED pin
int buttonState;
const int falso = 7;
// variables will change:
//int boto = 1; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(led, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(boto, INPUT);
pinMode(falso, INPUT);
}
void loop() {
// read the state of the pushbutton value:
if (buttonState = digitalRead(falso), HIGH){
if (buttonState = digitalRead(boto));
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(led, HIGH);
}
else {
// turn LED off:
digitalWrite(led, LOW);
}
}
//si no està l'interruptor falso, no podem encendre led
if (buttonState = digitalRead(falso), LOW){
digitalWrite(led, LOW);
}
}