Open johansmitsnl opened 1 year ago
a refactor to this works as the python code:
use rust_gpiozero::{InputDevice, LED};
use std::{thread, time::Duration};
fn main() {
// Led output
let mut led = LED::new(17);
// Create a button which is attached to Pin 17
let button = InputDevice::new_with_pullup(27);
led.on();
println!("Ready for input changed");
loop {
if button.is_active() {
println!("Button status is pressed");
led.on();
} else {
println!("Button status is released");
led.off();
}
thread::sleep(Duration::from_millis(300));
}
}
I thought that when I have this code it should switch from press to release and back. Instead it does only work on the flanks. So when I press it fires. When I release it does nothing. When I press again it fires the release.
Output is: < comments between here >
I try to make the same example as in Python:
Note that in Python I use the
GPIO.PUD_UP