Not able to set GPIO level
Posted: Thu May 11, 2023 8:34 pm
I have ESP32-C3-wroom-02 dev kit and i want to use a GPIO to set it high or low based on my requirement.
I tried the following code, but the GPIO18 is not changing
I tried the following code, but the GPIO18 is not changing
Code: Select all
#include <stdio.h>
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <unistd.h>
#define LED_PIN 18
void app_main(void)
{
gpio_set_direction(GPIO_NUM_18, GPIO_MODE_OUTPUT);
int ON = 0;
while(true)
{
ON = !ON;
gpio_set_level(GPIO_NUM_18, ON);
sleep(1);
}
}