Skip to content

Instantly share code, notes, and snippets.

@esmarr58
Created January 23, 2024 12:46
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 esmarr58/927443c9b3e561dd94d8463a4000bf1b to your computer and use it in GitHub Desktop.
Save esmarr58/927443c9b3e561dd94d8463a4000bf1b to your computer and use it in GitHub Desktop.
#include <unistd.h>
#include "sdkconfig.h"
#include "driver/gpio.h"
#define pinLED 4
#define ALTO 1
#define BAJO 0
int tiempoBajo = 19500;
int tiempoAlto = 50;
int periodo = 19000;
int contadorTiempo = 0;
void app_main(void){
gpio_reset_pin(pinLED);
gpio_set_direction(pinLED, GPIO_MODE_OUTPUT);
while (true){
gpio_set_level(pinLED, ALTO);
usleep(tiempoAlto);
gpio_set_level(pinLED, BAJO);
usleep(tiempoBajo);
contadorTiempo++;
if(contadorTiempo > 50){
contadorTiempo = 0;
tiempoAlto += 100;
}
if(tiempoAlto > 2600){
tiempoAlto = 500;
tiempoBajo = 19500;
}
else{
tiempoBajo = periodo-tiempoAlto;
}
//asm("nop");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment