En esta práctica si pulsamos el pulsador tiene que salir en el monitor serial "presionado" y si no lo estamos pulsando tiene que poner "no presionado".
Código:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int led1 = 2;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(led1, INPUT);
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
if ( digitalRead(led1) ==HIGH){
digitalWrite (led,HIGH) ;
Serial.println("PRESIONADO");
delay(100);
}
else {
digitalWrite (led,LOW);
Serial.println("NO PRESIONADO");
delay(100);
}
}