You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
use rust_gpiozero::{Button,Debounce,LED};use std::time::Duration;fnmain(){// Led outputlet led = LED::new(17);// Create a button which is attached to Pin 27letmut button = Button::new(27)// Add debouncing so that subsequent presses within 100ms don't trigger a press.debounce(Duration::from_millis(100));
led.off();println!("Ready for input changed");
button.wait_for_press(None);println!("Button status is pressed {}", button.is_active());
led.on();
button.wait_for_release(None);println!("Button status is released {}", button.is_active());
led.off();}
Output is:
< comments between here >
Ready for input changed => Led is off
< Press button >
Button status is pressed false < Why is status false since it is pressed? >
< Release button >
< Nothing happens wait for 2 seconds >
<Press button >
Button status is released false
use rust_gpiozero::{InputDevice,LED};use std::{thread, time::Duration};fnmain(){// Led outputletmut led = LED::new(17);// Create a button which is attached to Pin 17let 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
The text was updated successfully, but these errors were encountered: