Created
September 28, 2021 14:41
-
-
Save benevpi/0dec0e77d575138017d4b591c703da1b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Write your code here :-) | |
"""CircuitPython Essentials Digital In Out example""" | |
import time | |
import board | |
from digitalio import DigitalInOut, Direction | |
import touchio | |
# LED setup. | |
LED_pins = [board.GP0, board.GP1, board.GP2, board.GP3, board.GP4, board.GP5, board.GP6, | |
board.GP7, board.GP8, board.GP9, board.GP10, board.GP11, board.GP12, board.GP13, board.GP14, | |
board.GP15, board.GP16, board.GP17, board.GP18, board.GP19, board.GP20, board.GP21, board.GP22, | |
board.GP26] | |
leds = [] | |
for pin in LED_pins: | |
led = DigitalInOut(pin) | |
led.direction = Direction.OUTPUT | |
leds.append(led) | |
touch_pad_left = board.GP27 | |
touch_left = touchio.TouchIn(touch_pad_left) | |
touch_pad_right = board.GP28 | |
touch_right = touchio.TouchIn(touch_pad_right) | |
posn = 0 | |
pattern = 0 | |
speed = 5 | |
while True: | |
for led in leds: | |
led.value = False | |
if pattern == 0: | |
leds[posn].value = True | |
else: | |
leds[posn].value = True | |
leds[23-posn].value = True | |
print(posn) | |
time.sleep(speed/10) | |
print(touch_left.raw_value) | |
if touch_left.value and not (posn == 23 or posn == 0): | |
pattern = (pattern + 1) % 2 | |
if touch_right.value: | |
speed = (speed + 1) % 10 | |
posn = (posn+1)%24 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment