Last active
June 15, 2019 07:04
-
-
Save tedysaputro/a74d8d940518676f2d0079e5e67bc10b to your computer and use it in GitHub Desktop.
Blink ESP32
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 "freertos/FreeRTOS.h" | |
#include "freertos/task.h" | |
#include "esp_system.h" | |
#include "esp_spi_flash.h" | |
#include "driver/gpio.h" | |
#include "sdkconfig.h" | |
#define BLINK_GPIO 2 | |
void app_main() | |
{ | |
/* Configure the IOMUX register for pad BLINK_GPIO (some pads are | |
muxed to GPIO on reset already, but some default to other | |
functions and need to be switched to GPIO. Consult the | |
Technical Reference for a list of pads and their default | |
functions.) | |
*/ | |
gpio_pad_select_gpio(BLINK_GPIO); | |
/* Set the GPIO as a push/pull output */ | |
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT); | |
while(1) { | |
/* Blink off (output low) */ | |
printf("Turning off the LED\n"); | |
gpio_set_level(BLINK_GPIO, 0); | |
vTaskDelay(1000 / portTICK_PERIOD_MS); | |
/* Blink on (output high) */ | |
printf("Turning on the LED\n"); | |
gpio_set_level(BLINK_GPIO, 1); | |
vTaskDelay(1000 / portTICK_PERIOD_MS); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment