But for GPIO_4 its always low. Does this pin require special configuration? I looked throughout the documentation and didn't find such case.
Code: Untitled.c Select all
#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));
}
}