Skip to content

Instantly share code, notes, and snippets.

@viccarre
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viccarre/4e9306dd0bc46a24b4b5 to your computer and use it in GitHub Desktop.
Save viccarre/4e9306dd0bc46a24b4b5 to your computer and use it in GitHub Desktop.
Este código es para el proyecto con Hablobajito
// 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