Code: Select all
# Pico:ed V2 Graphics demonstration using CircuitPython
# Tony Goodhew 27th September 2022
import board
import digitalio
import pwmio # for Buzzer
import time
from picoed import *
W = display.width
H = display.height
def blit(s,x,y,w,h,v): # Insert image in frame
for xx in range(w):
for yy in range(h):
c = s[xx+yy*w]*v
display.pixel(x+xx,y+yy,c)
# Titles and Buzzer demo
#display.scroll("Tony Goodhew")
piezo = pwmio.PWMOut(board.BUZZER_GP3,duty_cycle=0, frequency=440, variable_frequency=True) # ERROR !!!
def play_note(note):
piezo.frequency = note
piezo.duty_cycle = 65535 // 2
time.sleep(0.25)
piezo.duty_cycle = 0
time.sleep(0.05)
for i in range(2):
play_note(494)
time.sleep(0.2)
play_note(262)
time.sleep(0.2)
play_note(294)
time.sleep(0.2)
piezo.deinit()
display.scroll("Graphics test of Pico:ed V2")
#Brightness
display.fill(1) # Fill display with dimmest pixels
time.sleep(2)
display.fill(10) # Fill display with brighter pixels
time.sleep(2)
Traceback (most recent call last):
File "<stdin>", line 22, in <module>
ValueError: BUZZER in use
Cannot get this to run. I halted program while buzzer was active and reset button and unplugging to not appear to reset the processor.
Suggestions please.