Buttons
The button feature makes it easier to work with buttons, when compared to reading a digital pin for example.
This feature is not available on all pins. However, Digital Read can be used instead, which is available on all pins. DUELink Spider supports Button
on pins 1,2,3,4 plus buttons 'A' and 'B'.
Tip
The timeout for Button Down
and Button Up
are fixed to two seconds. Calling after two seconds from last press or release returns 0.
Button.Enable(pin, enable) - Activates a pin to be used as a button
pin: Pin number
enable: True = enable, false = disabledButton.JustReleased(pin)
pin: Pin number
Returns: True after release first time called. If called again returns falsebool Button.JustPressed(pin) - Checks if a button was pressed
pin: Pin number
Returns: True if button was pressed recently and continues to return 1 until the button is released
This example checks button 'a'.
duelink.Button.Enable('a', True);
while True:
d = duelink.Button.JustPressed('a')
u = duelink.Button.JustReleased('a')
if (d):
print("Button A down")
if (u):
print("Button A up")
time.sleep(0.2);