Skip to content

Instantly share code, notes, and snippets.

@hawkz
Created January 26, 2016 16:53
Show Gist options
  • Save hawkz/ce30fe8fc35dc13892ef to your computer and use it in GitHub Desktop.
Save hawkz/ce30fe8fc35dc13892ef to your computer and use it in GitHub Desktop.
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