// Blinks an LED using ESP-IDF (std version)
// Assumes a LED is connected to GPIO4

use esp_idf_hal::delay::Delay;
use esp_idf_hal::gpio::*;
use esp_idf_hal::peripherals::Peripherals;
use esp_idf_sys as _;
use log::info;

fn main() {
    // Initialize the ESP-IDF runtime
    esp_idf_sys::link_patches();
    esp_idf_svc::log::EspLogger::initialize_default();

    // Take all the hardware peripherals
    let peripherals = Peripherals::take().unwrap();
    let pins = peripherals.pins;

    // Configure GPIO4 as output for the LED
    let mut led = pins.gpio4.into_output().unwrap();
    let mut delay = Delay::new();

    info!("Starting LED blink loop...");

    loop {
        info!("Toggling LED");
        led.toggle().unwrap();
        delay.delay_ms(500);
    }
}
Loading
esp32-c3-devkitm-1