How to set pin to output mode using ESP-IDF
Use this snippet to define a pin as output using the ESP-IDF framework (e.g. using PlatformIO):
gpio_config_t io_conf;
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
// Define the pin here (e.g. (1ULL << 2) for GPIO9)
io_conf.pin_bit_mask = (1ULL << 2);
io_conf.pull_down_en = 0;
io_conf.pull_up_en = 0;
gpio_config(&io_conf);
The example above configuresĀ GPIO2
as an output. Use (1ULL << 3)
to configure GPIO3 as an output