Buzzer pico explorer no sound

Hi, I am Andre new to the pico explorer!
After playing with micropython on the LCD display (great results) I try to make a sound when I push key A-B_X or Y

Until now no sound at all…

Here are some code snips

from pimoroni import Button
buzzer = Buzzer(0)
while True:
if button_x.read():
display.set_pen(WHITE) # change the pen colour
display.text(“Button X pressed”, 10,200,scale=2) # display some text on the screen
display.update()
buzzer.set_tone(1750)
time.sleep(1)
buzzer.set_tone(0)
display.set_pen(RED)
display.rectangle(10,200,239,16)
display.update()
else:
time.sleep(0.1)

Is buzzer.set_tone implemented in the latest micro python release?

greetings Andre

From the example readme - “(you’ll need to connect AUDIO to GP0 with a jumper wire to hear noise)”.

For reasons (that I don’t entirely understand!), you need a jumper to connect up the buzzer!

Thanks, I did understand to connect the buzzer to a gpio pin. So I did but even if I connect audio for a short time to 3V3 no sound…

Hmm; have you tried running the examples? That at least should narrow the issue down to a hardware issue or trouble with your code.

I know it was working, and while it’s possible it’s broken without anyone noticing in the latest releases it seems improbable. If you can’t get it to work with the examples I’ll try and dig mine out, stick a fresh firmware on it and try to make it beep :-)

Thanks ahniak for the quick response. Later this evening I will put in a new firmware. Fine evening!

Andre

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

JFYI, code tags are three ` at top of code and three more at end of code.
Doing that will retain indents etc. And stop the accidental bold text etc.
I had to ask how it was done, ;)

sorry for this I will use them in the next posts!

No worries, there is no easy obvious way to do it. That’s why I mentioned it.