Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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