Unable to toggle esp32 c6 GPIO_NUM_4
Posted: Wed Feb 21, 2024 8:40 am
Hi, I am not sure why i am unable to toggle esp32 c6 GPIO_4. I am able to toggle GPIO_5. Same code works for esp32.
But for GPIO_4 its always low. Does this pin require special configuration? I looked throughout the documentation and didn't find such case.
But for GPIO_4 its always low. Does this pin require special configuration? I looked throughout the documentation and didn't find such case.
- #include <stdio.h>
- #include "esp_log.h"
- #include "lvgl.h"
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "driver/gpio.h"
- static const char *TAG = "WATCH";
- static bool state;
- void app_main(void)
- {
- ESP_LOGD(TAG, "Start Main");
- gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT);
- gpio_set_level(GPIO_NUM_4, 1);
- state = false;
- while (true)
- {
- if (state == true)
- {
- gpio_set_level(GPIO_NUM_4, 0);
- state = false;
- ESP_LOGD(TAG, "Motor off");
- }
- else
- {
- state = true;
- gpio_set_level(GPIO_NUM_4, 1);
- ESP_LOGD(TAG, "Motor on");
- }
- vTaskDelay(pdMS_TO_TICKS(1000));
- }
- }