Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://cursoarduinomega.blogspot.com.ar/2015/04/boton-enciende-led.html
- int boton = 4;
- int led = 6;
- void setup() {
- pinMode(boton, INPUT);
- pinMode(led, OUTPUT);
- }
- int estado = 0; //guarda el estado del botón
- int estadoAnterior = 0; //guarda el estado anterior del botón
- int salida = 0; // 0 = led pagado, 1 = led encendido
- void loop() {
- estado = digitalRead(boton); //lee el estado del boton
- if(( estado == HIGH ) && ( estadoAnterior == LOW )){
- salida = 1 - salida;
- }
- estadoAnterior = estado;
- if ( salida == 1 ){
- digitalWrite(led, HIGH);
- }
- else{
- digitalWrite(led, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement