#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/gpio.h" #define LED_RED GPIO_NUM_5 #define LED_GREEN GPIO_NUM_2 #define LED_BLUE GPIO_NUM_4 static TimerHandle_t led1 , led2 ,led3= NULL ; void TimerLedControl(TimerHandle_t xtimer){ uint32_t led_timer_id = (uint32_t) pvTimerGetTimerID(xtimer) ; //red led if (led_timer_id == 0){ gpio_set_level(LED_RED,!gpio_get_level(LED_RED)); } //green led if (led_timer_id == 1){ gpio_set_level(LED_GREEN,!gpio_get_level(LED_GREEN)); } //blue led if (led_timer_id == 2){ gpio_set_level(LED_BLUE,!gpio_get_level(LED_BLUE)); } printf("inside timer\n"); } extern "C" void app_main() { //setting GPIO Direction (INPUT , OUTPUT) gpio_set_direction(LED_RED, GPIO_MODE_OUTPUT); gpio_set_direction(LED_GREEN, GPIO_MODE_OUTPUT); gpio_set_direction(LED_BLUE, GPIO_MODE_OUTPUT); //timer tasks led1 = xTimerCreate("LED Red", pdMS_TO_TICKS(100),pdTRUE,(void *) 0,TimerLedControl); led2 = xTimerCreate("LED Green", pdMS_TO_TICKS(100),pdTRUE,(void *) 1,TimerLedControl); led3 = xTimerCreate("LED Blue", pdMS_TO_TICKS(100),pdTRUE,(void *) 2,TimerLedControl); xTimerStart(led1,0); xTimerStart(led2,0); xTimerStart(led3,0);