blob: 01a9e8a3f0bccb8a3e82c998f6d2334f978e4f22 [file] [log] [blame]
#![no_std]
use core::fmt::Write;
use libtock::console::Console;
use libtock::gpio::GpioPinUnitialized;
use libtock::gpio::InputMode;
use libtock::result::TockResult;
use libtock::timer;
use libtock::timer::Duration;
// example works on p0.03
async fn main() -> TockResult<()> {
let mut console = Console::new();
let pin = GpioPinUnitialized::new(0);
let pin = pin.open_for_read(None, InputMode::PullDown)?;
loop {
if pin.read() {
writeln!(console, "true")?;
} else {
writeln!(console, "false")?;
}
timer::sleep(Duration::from_ms(500)).await?;
}
}