SHARE
TWEET

Untitled




Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- const int
- LED = 13,
- BUTTON = 7;
- int
- val = 0,
- oldval = 0,
- state = 0;
- void setup() {
- pinMode(LED, OUTPUT);
- pinMode(BUTTON, INPUT); //setea los pins, cual es el LED y cual el boton
- }
- void loop() {
- val = digitalRead(BUTTON); //devuelve 1 o 0, dependiendo de si se aprieta el boton o no
- if (val == HIGH && oldval == LOW) { //high = 1, low = 0
- state = 1 - state;
- delay(10);
- }
- oldval = val;
- if (state == 1) digitalWrite(LED, HIGH); //prende la luz
- else digitalWrite(LED, LOW); //la apaga
- }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.