esp32 blink experiment

#include<stdio.h>
#include"freertos/FreeRTOS.h"
#include"freertos/task.h"
#include"driver/gpio.h"
#include"sdkconfig.h"

#define BLINK_GPIO 2

void blink_task(void *pvParameter)
{
gpio_pad_select_gpio(BLINK_GPIO); //fill the gpio to be used 0~39
gpio_set_direction(BLINK_GPIO,GPIO_MODE_OUTPUT);//set the direction
while(1){
gpio_set_level(BLINK_GPIO,0);//set low Level
vTaskDelay(1000/portTICK_PERIOD_MS);//Delay 1s
gpio_set_level(BLINK_GPIO,1);
vTaskDelay(1000/portTICK_PERIOD_MS);
}
}
void app_main()
{
xTaskCreate(
&blink_task,
"blink_task",
configMINIMAL_STACK_SIZE,
NULL,
5,
NULL
);
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325205849&siteId=291194637