Skip to content

Instantly share code, notes, and snippets.

@agrgal
Created May 20, 2021 17:23
Show Gist options
  • Save agrgal/e47e32fa88a34c117147febea6b28c06 to your computer and use it in GitHub Desktop.
Save agrgal/e47e32fa88a34c117147febea6b28c06 to your computer and use it in GitHub Desktop.
#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