I'm a new user of Raspberry and I'm now playing with the GPIOZero library.
So far so good, when I try to use 4 different pin to simulate 4 arrow keys with buttons, everything works properly.
Now, I would like to use as well 2 of the pins keeping them old let's say for 1 sec .
first , I'm already blocked using only 1 button :
When I define a second check for my GPIO pin, it says that it is already use ( indeed as it is monitoring for a single push )
My final goal is : if I press the 2 button simulteanously during 1 sec, it generate "enter" as ex ( through the pyautogui library )
Is there something I'm missing here ? a trick to have both working ? Code below to be more understandable
Code: Select all
from gpiozero import Button from signal import pause import pyautogui def send_l(): pyautogui.press('left') def send_r(): pyautogui.press('right') def send_u(): pyautogui.press('up') def send_d(): pyautogui.press('down') def send_ok(): pyautogui.press('enter') bleft = Button(4) bright = Button(17) bup = Button(27) bdown= Button(22) b_ok = Button(4, hold_time=1) bleft.when_pressed = send_l bright.when_pressed = send_r bup.when_pressed = send_u bdown.when_pressed = send_d b_ok.when_held = send_ok pause()