Created
May 20, 2021 17:23
-
-
Save agrgal/e47e32fa88a34c117147febea6b28c06 to your computer and use it in GitHub Desktop.
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
#include <Arduino.h> | |
#define SEMIPERIODO 1000 | |
unsigned char salida = 0; | |
unsigned estado_salida = 0; | |
unsigned long tiempo_anterior = 0; | |
unsigned long tiempo =0; | |
void setup() { | |
// put your setup code here, to run once: | |
DDRB = DDRB | (1<<PB2); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
tiempo = millis(); | |
if (tiempo - tiempo_anterior>SEMIPERIODO) { | |
tiempo_anterior = tiempo; | |
if (estado_salida==0) { | |
estado_salida=1; | |
salida = salida | (1<<PB2); | |
} else { | |
estado_salida=0; | |
salida =salida & ~(1<<PB2); | |
} | |
} | |
PORTB = salida; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment