Created
January 23, 2024 12:46
-
-
Save esmarr58/927443c9b3e561dd94d8463a4000bf1b 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 <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