From dae3d42264b7d1ebb7f7b1b3967d866c49135401 Mon Sep 17 00:00:00 2001 From: memdmp Date: Sat, 25 Jan 2025 04:33:41 +0100 Subject: feat: things --- src/bin/btn-test.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/bin/btn-test.rs (limited to 'src/bin/btn-test.rs') diff --git a/src/bin/btn-test.rs b/src/bin/btn-test.rs new file mode 100644 index 0000000..b33e402 --- /dev/null +++ b/src/bin/btn-test.rs @@ -0,0 +1,31 @@ +#![no_std] +#![no_main] + +use esp_backtrace as _; +use esp_hal::{ + gpio::{Input, Level, Output, Pull}, + main, +}; +use esp_println::println; + +#[main] +fn main() -> ! { + let peripherals = esp_hal::init(esp_hal::Config::default()); + + println!("Hello world!"); + + // Set GPIO7 as an output, and set its state high initially. + let mut led = Output::new(peripherals.GPIO1, Level::Low); + let button = Input::new(peripherals.GPIO3, Pull::Up); + + // Check the button state and set the LED state accordingly. + loop { + if button.is_high() { + println!("high"); + led.set_high(); + } else { + println!("low"); + led.set_low(); + } + } +} -- cgit v1.2.3