Last active
July 4, 2022 20:35
-
-
Save recantha/bcfcaecf0c40cc66f330c643cea19be1 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
import time | |
import board | |
from digitalio import DigitalInOut, Direction, Pull | |
import pwmio | |
from analogio import AnalogIn | |
led1 = pwmio.PWMOut(board.GP7, frequency=5000, duty_cycle=0) | |
led2 = DigitalInOut(board.GP8) | |
led2.direction = Direction.OUTPUT | |
led3 = DigitalInOut(board.GP9) | |
led3.direction = Direction.OUTPUT | |
led4 = DigitalInOut(board.GP10) | |
led4.direction = Direction.OUTPUT | |
led5 = DigitalInOut(board.GP11) | |
led5.direction = Direction.OUTPUT | |
led6 = DigitalInOut(board.GP12) | |
led6.direction = Direction.OUTPUT | |
led7 = DigitalInOut(board.GP17) | |
led7.direction = Direction.OUTPUT | |
led8 = DigitalInOut(board.GP16) | |
led8.direction = Direction.OUTPUT | |
leds = [led2,led3,led4,led5,led6,led7,led8] | |
buzzer = DigitalInOut(board.GP21) | |
buzzer.direction = Direction.OUTPUT | |
buttonGP4 = DigitalInOut(board.GP4) | |
buttonGP4.direction = Direction.INPUT | |
buttonGP4.pull = Pull.DOWN | |
buttonGP3 = DigitalInOut(board.GP3) | |
buttonGP3.direction = Direction.INPUT | |
buttonGP3.pull = Pull.DOWN | |
pot = AnalogIn(board.A1) | |
while True: | |
if buttonGP4.value: | |
for single_led in leds: | |
if buttonGP4.value: | |
single_led.value = True | |
time.sleep(0.1) | |
else: | |
for single_led in leds: | |
single_led.value = False | |
if buttonGP3.value: | |
buzzer.value = True | |
else: | |
buzzer.value = False | |
led1.duty_cycle = pot.value | |
time.sleep(0.01) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment