Created
January 29, 2024 18:05
-
-
Save esmarr58/0ec16d11f12a4e90bf7e618fcf9ce9f5 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 <stdio.h> | |
#include <stdbool.h> | |
#include <unistd.h> | |
#include "freertos/FreeRTOS.h" | |
#include "freertos/task.h" | |
#include "driver/gpio.h" | |
#include "esp_log.h" | |
#include "sdkconfig.h" | |
#define A 41 | |
#define B 40 | |
#define C 39 | |
#define D 38 | |
#define E 37 | |
#define F 36 | |
#define G1 35 | |
#define G2 45 | |
#define cero 0xFC | |
#define uno 0x60 | |
#define dos 0xDB | |
#define tres 0xF3 | |
#define cuatro 0x67 | |
#define cinco 0xB7 | |
#define seis 0xBF | |
#define siete 0xE3 | |
#define ocho 0xFF | |
#define nueve 0xE7 | |
uint8_t numeros[10] = {cero, uno, dos, tres, cuatro, cinco, seis, siete, ocho, nueve}; | |
void display(uint8_t numero){ | |
gpio_set_level(A, !((numeros[numero] & 0b10000000) >> 7)); | |
gpio_set_level(B, !((numeros[numero] & 0b01000000) >> 6)); | |
gpio_set_level(C, !((numeros[numero] & 0b00100000) >> 5)); | |
gpio_set_level(D, !((numeros[numero] & 0b00010000) >> 4)); | |
gpio_set_level(E, !((numeros[numero] & 0b00001000) >> 3)); | |
gpio_set_level(F, !((numeros[numero] & 0b00000100) >> 2)); | |
gpio_set_level(G1,!((numeros[numero] & 0b00000010) >> 1)); | |
gpio_set_level(G2,!((numeros[numero] & 0b00000001) >> 0)); | |
} | |
void configuraciones(){ | |
gpio_reset_pin(A); | |
gpio_reset_pin(B); | |
gpio_reset_pin(C); | |
gpio_reset_pin(D); | |
gpio_reset_pin(E); | |
gpio_reset_pin(F); | |
gpio_reset_pin(G1); | |
gpio_reset_pin(G2); | |
gpio_set_direction(A, GPIO_MODE_OUTPUT); | |
gpio_set_direction(B, GPIO_MODE_OUTPUT); | |
gpio_set_direction(C, GPIO_MODE_OUTPUT); | |
gpio_set_direction(D, GPIO_MODE_OUTPUT); | |
gpio_set_direction(E, GPIO_MODE_OUTPUT); | |
gpio_set_direction(F, GPIO_MODE_OUTPUT); | |
gpio_set_direction(G1, GPIO_MODE_OUTPUT); | |
gpio_set_direction(G2, GPIO_MODE_OUTPUT); | |
} | |
void app_main(void) | |
{ | |
configuraciones(); | |
while (true) { | |
for(int i =0; i<=9; i++){ | |
display(i); | |
sleep(1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment