Hello ahnlak, I just managed to get the buzzer make any sound…
I make some changes to the example
import time
from picographics import PicoGraphics, DISPLAY_PICO_EXPLORER
from pimoroni import Buzzer
display = PicoGraphics(display=DISPLAY_PICO_EXPLORER)
Create a buzzer on pin 0
Don’t forget to wire GP0 to AUDIO!
BUZZER = Buzzer(0)
BLACK = display.create_pen(0, 0, 0)
GREEN = display.create_pen(0, 255, 0)
this handy list converts notes into frequencies, which you can use with the explorer.set_tone function
tones = {
“B0”: 1220,
“C1”: 1230,
“CS1”: 1240,
“D1”: 1250
}
put the notes for your song in here!
song = [“B0”, “C1”, “CS1”, “D1”]
def clear(): # this function clears Pico Explorer’s screen to black
display.set_pen(BLACK)
display.clear()
display.update()
def playtone(frequency): # this function tells your program how to make noise
BUZZER.set_tone(frequency)
def bequiet(): # this function tells your program how not to make noise
BUZZER.set_tone(-1)
def playsong(song): # this function plays your song
a = 0 # this variable keeps track of the visualiser bars
for i in range(len(song)):
if (song[i] == “P”):
bequiet()
else:
playtone(tones[song[i]])
time.sleep(5) # change this number if you want to alter how long the notes play for
bequiet()
clear()
playsong(song)
clear()
The sound is not very loud and I was wondering is there a way to increase the volume?
Also if I want to play just one tone like
Buzzer.set_tone(1750)
and increase volume with Buzzer.duty(70)
I hope in the next library there will be something like this…
Anyway thanks for your help!
greetings Andre