47 lines
1.2 KiB
C
Executable File
47 lines
1.2 KiB
C
Executable File
#include <stdio.h>
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "driver/gpio.h"
|
|
#include "esp_log.h"
|
|
|
|
// Define which GPIO pin to use (most ESP32 boards have LED on GPIO2)
|
|
#define LED_PIN GPIO_NUM_13
|
|
|
|
// Tag for logging
|
|
static const char* TAG = "BLINK";
|
|
|
|
void app_main(void)
|
|
{
|
|
ESP_LOGI(TAG, "Starting blink example!");
|
|
|
|
// Configure the GPIO pin as output
|
|
gpio_config_t io_conf = {
|
|
.pin_bit_mask = (1ULL << LED_PIN), // Bit mask for the pin
|
|
.mode = GPIO_MODE_OUTPUT, // Set as output mode
|
|
.pull_up_en = GPIO_PULLUP_DISABLE, // Disable pull-up
|
|
.pull_down_en = GPIO_PULLDOWN_DISABLE, // Disable pull-down
|
|
.intr_type = GPIO_INTR_DISABLE // Disable interrupt
|
|
};
|
|
|
|
// Apply the configuration
|
|
gpio_config(&io_conf);
|
|
|
|
ESP_LOGI(TAG, "GPIO configured! Starting blink loop...");
|
|
|
|
// Main loop
|
|
while(1) {
|
|
// Turn LED on
|
|
gpio_set_level(LED_PIN, 1);
|
|
ESP_LOGI(TAG, "LED ON");
|
|
|
|
// Wait 1 second
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
|
|
// Turn LED off
|
|
gpio_set_level(LED_PIN, 0);
|
|
ESP_LOGI(TAG, "LED OFF");
|
|
|
|
// Wait 1 second
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
}
|
|
} |