Created
January 26, 2016 16:53
-
-
Save hawkz/ce30fe8fc35dc13892ef 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
import pyb | |
switch = pyb.Switch() | |
leds = [pyb.LED(i+1) for i in range(4)] | |
accel = pyb.Accel() | |
i = 0 | |
while not switch(): | |
y = accel.y() | |
i = (i + (1 if y > 0 else -1)) % len(leds) | |
leds[i].toggle() | |
pyb.delay(10 * max(1, 30 - abs(y))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment