use esp_idf_hal::delay::Ets;
use esp_idf_hal::gpio::*;
use esp_idf_hal::peripherals::Peripherals;
use std::thread;
use std::time::Duration;
fn main() {
esp_idf_sys::link_patches(); // Required to initialize system
println!("Hello world!");
let peripherals = Peripherals::take().unwrap();
let pins = peripherals.pins;
let mut led = PinDriver::output(pins.gpio4).unwrap();
let btn = PinDriver::input(pins.gpio2).unwrap();
loop {
if btn.is_high() {
println!("Button pressed");
led.set_high().unwrap();
} else {
led.set_low().unwrap();
}
thread::sleep(Duration::from_millis(500));
}
}