Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save benspargo89/705734adbbc9c6330edd0d9fb7e15497 to your computer and use it in GitHub Desktop.
Save benspargo89/705734adbbc9c6330edd0d9fb7e15497 to your computer and use it in GitHub Desktop.
from gpiozero import Motor, InputDevice
from time import sleep, time
SAMPLETIME = 1
r = Motor(forward=5, backward=6)
state = False
b = InputDevice(4)
r.forward()
count = 0
sleep(1)
start = time()
while time() - start < .1:
status = b.is_active
if state != status:
state = status
count += 1
r.stop()
print('Done')
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment