Last active
August 29, 2015 14:04
-
-
Save viccarre/4e9306dd0bc46a24b4b5 to your computer and use it in GitHub Desktop.
Este código es para el proyecto con Hablobajito
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vamor a configurar los pines como en Arduino: | |
const int buttonPin = 1; // aquí ponermos el pin del boton que es el velcro | |
const int ledPin = 2; // aquí ponemos el pin de la señal del LED | |
int buttonState = 0; // variable para leer el boton | |
void setup() { | |
// configuramos el LED como salida | |
pinMode(ledPin, OUTPUT); | |
// configuramos el pin del velcro como entrada | |
pinMode(buttonPin, INPUT_PULLUP); | |
} | |
void loop(){ | |
// leemos el estado del boton (velcro) | |
buttonState = digitalRead(buttonPin); | |
// preguntamos si el velcro no esta cerrado | |
//si esta abierto entonces prendemos los LEDs | |
if (buttonState == HIGH) { | |
// aquí prendemos los LED's | |
digitalWrite(ledPin, HIGH); | |
} | |
else { | |
// aquí apagamos los LED's: | |
digitalWrite(ledPin, LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment