/* Blink Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "led_strip.h"
#include "sdkconfig.h"
#define LED_PIN GPIO_NUM_2
static const char *TAG = "01-LED-Blink-Demo";
void configLed()
{
gpio_reset_pin(LED_PIN);
gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT);
}
void ledTask()
{
while (1)
{
gpio_set_level(LED_PIN, 1);
ESP_LOGI(TAG, "LED ON");
vTaskDelay(1000 / portTICK_PERIOD_MS);
gpio_set_level(LED_PIN, 0);
ESP_LOGI(TAG, "LED OFF");
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
void app_main(void)
{
configLed();
xTaskCreate(ledTask, TAG, 1024 * 4, NULL, 1, NULL);
}
01-LED-Blink-Demo(开发环境esp-idf)
最新推荐文章于 2024-09-24 08:48:12 发布