I’m trying to light up an LED and play a buzzer noise at the same time. Here is my code so far:
Import RPi.GPIO as GPIO
Import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(7, GPIO.OUT)
while True:
GPIO.output(7, 1)
time.sleep(2)
GPIO.output(7,0)
time.sleep(2)
GPIO.cleanup()
and here is how my RBp is connected:
The LED lights up as expected but all I’m getting from the piezo is a very short static noise as if it’s getting electricity. But no sustaining noise.
I don’t think theres anything wrong with the code as I’ve seen multiple examples online that are basically identical and work with no issues. The buzzer I’m using is from the arduino starter kit if thats any help.
If anyone can help me figure out why it’s not working that would be very appreciated!
Question
/ to continue, …
Answer
Well, it is the same old story of:
“How come the relay/buzzer/xyx, … works in her good old Arduino but not in my poor new Rpi?
Now the bad Arduino guys are LOL at me. Other similarly miserable Rpi newbies are also weeping in the dark.
And it is the same old reason:
The reason is that those Arduino devices are designed to start/work/active/trigger at Low level signal, and stop/rest/nonactive/disable/untrigger at Arduino Hig Level Signal of > 4V.
Rpi is a weak guy and its High level signal is only around 3.2V. So the reason is “Poor Rpi’s Low level signal is OK, but High level signal is not as high as the strong Arduino and therefore device refuses to respond.
See my long answer to a similar question for more details:
Active Buzzer makes sound on both LOW and HIGH – @hbo rpi.stackexchange, 2019apr27
/ to continue, …
References
/ to continue, …
Appendices
Appendix A – Buzzer Spec
Appendix B – Buzzer Schematic
/ to continue, …
End of Answer
Categories: Uncategorized



sudo pigpiodthenpigs p 7 128Any noise? – joan 6 hours ago