hi please i want to change the sound volume using potentiometer and a speaker with arduino.can you help me to do the connection circuit .thx in advance
kind regards
hi please i want to change the sound volume using potentiometer and a speaker with arduino.can you help me to do the connection circuit .thx in advance
kind regards
ok - so: set working system only with microbit and speaker module and check it.
then: disconnect only connection between microbit output and speaker module input
get potentiometer of proper value (what resistance is yours? it should be printed somewhere on the case)
potentiometer has three pins - find which one is regulated (let's call it "center pin")
connect one pin (not "center pin") to microbits output
connect another pin (not "center pin") to the ground
connect "center pin" to speaker module's input
is it clear or is it something that needs additional explanation?
yes thx i will connect out pin of potentiometer to p2 of microbit and sig pin of speaker to p1 so i make this program shared and i will try
i hope it will work
i´m eager to know
Then this Arduino schematics will help
Ok - I have checked your code and now I understand...
You are trying to tune volume in your code using input from potentiometer connected to another pin...
What I am trying to propose is to reduce/regulate signal from microbit at "speaker's" input
So - only one of two: either put potentiometer between microbit and "speaker" or devise code that will scale output on microbit pin using any metric (for example - potentiometer connected to another contact or something else)
You can make an audio amplifier with LM386. If you see the datasheet, you will find designs of Amplifiers with different gains. every design includes a potentiometer. You will be able to control volume with that. You can interface the amplifier with Arduino if needed.
I think you are not doing what you thin you are doing:
so - you get voltage sample from P2 (from potentiometer), then write it to the output pin, then play sound disregarding pot value
check if music.playSoundEffect has variable setting volume and use pot variable to change volume