I'm using the PCM(http://highlowtech.org/?p=1963) library on the Arduino nano, I'm plugging the speaker(https://www.amazon.com/gp/product/B07WZP4QFK/ref=ox_sc_act_title_3?smid=A2O4FZXIRZDLHA&psc=1) into pin 11 and ground, but the example file won't work.
-
They don't say much about their wiring on that site. And you haven't shown your wiring. It seems likely that the code is fine but what you have attached to pin 11 isn't. Description, diagram, pictures etc would be helpful.– timemageCommented Dec 15, 2020 at 17:13
-
added a diagram– EpicmaniaCommented Dec 15, 2020 at 17:19
-
I have a sense of what the answer will be when someone posts it. It probably won't be me, unless on one else does. For their sake, show the actual speaker, and in particular, any writing on it. It may be useful for them in writing a more complete answer of what you need to do.– timemageCommented Dec 15, 2020 at 17:23
-
1test the pin ... replace the speaker with an LED– jsotolaCommented Dec 15, 2020 at 18:25
-
2Perhaps. If you were testing it with the LED (and resistor) instead of speaker using the example sketch, you might as well go a step further and test that same pin by substituting its number into the blink sketch. I have some reservations about how you're hooking a 4 ohm speaker directly to an Arduino pin. It's possible that doing this killed the pin. Normally, I'd say likely, but that you "tried it on the uno and it works" casts some doubt on that theory. It seems like a bad idea in any case, and until you know differently I'd avoid hooking it directly to your pins.– timemageCommented Dec 16, 2020 at 2:23
1 Answer
I guess the Nano had a sketch which was setting pin 11 HIGH (using SPI?) as you turned it on with a 4 Ohm speaker attached without any other resistance. It created a short circuit and damaged the pin's circuit.
Using tone() or the PCM library with a speaker connected without additional resistor doesn't damage the pin immediately because it is then HIGH only for very short moments, but it stresses the pin circuit too.
The linked page recommends to use direct speaker connection because it is much louder then with a resistor in series, but this is a wrong advice. It should recommend an amplifier module for example with LM386 IC.
A piezo speaker has higher resistance so it can be connected directly to Arduino pin, but a piezo sounds loud only in high frequencies so with the PCM library the sound is like whispering.
-
-
-
is there really nothing I can do here, because I have more nano boards Commented Dec 17, 2020 at 13:23
-
use a 100 Ohm resistor in series with the speaker to test the library, but the sound will be weak. for good results use an amplifier module. shops have small amplifier modules for Arduino– Juraj ♦Commented Dec 17, 2020 at 14:04
-
ok, thank you! If this project didn't work out, my dad might never buy me parts again so this really helps Commented Dec 17, 2020 at 14:07