Advertisement
elektronek

Roman Kučera - ESP32 Blink

Nov 27th, 2019
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "freertos/FreeRTOS.h"
  3. #include "freertos/task.h"
  4. #include "driver/gpio.h"
  5. #include "sdkconfig.h"
  6.  
  7. void zapisPort(unsigned int cislo)
  8. {
  9.     for (int a=16; a<=22; a++)
  10.     {
  11.         gpio_set_level(a, (cislo & (1<<(a-16))));
  12.     }
  13. }
  14.  
  15. void app_main(void)
  16. {
  17.     unsigned int hodnota=0;
  18.     // Inicializace GPIO
  19.     for (int a=16; a<=22; a++)
  20.     {
  21.         gpio_pad_select_gpio(a);
  22.         gpio_set_direction(a, GPIO_MODE_OUTPUT);
  23.     }
  24.  
  25.     while(1) {
  26.         zapisPort(hodnota);
  27.         vTaskDelay(1000 / portTICK_PERIOD_MS);
  28.         if (hodnota < 0x3f0) hodnota++; else hodnota=0;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement