Created
May 12, 2020 00:26
-
-
Save benspargo89/705734adbbc9c6330edd0d9fb7e15497 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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