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
I don't know microbit and don't know language from the photo - could you share it using makecode.microbit.org as previous (it will translate)? The problem is that this webpage translates to my language that will be in turn unusable to you...
can you put block setVolume in loop before playing sound? something like this:
- read pot
- setVolume(pot)
- playSound()
and first verify that it correcly reads pot values when potentiometer position changes?
what is setSound called in your interface?
ok - this is different code - it changes frequency of tone using potentiometer connected to P2 (so potentiometer reading works)
playTone has definition playTone(frequency, duration)
can you check in main loop
- reading value of P2 to pot variable
- calling setVolume(pot) <- the same setVolume which you have had in previous version at the top with 127 value
- then playSound?
and of course it wouldn't allow for changing volume during playback - it is read only once per play...
I will advise for analog volume control
I think that it is rather strange when volume changes along with frequency - is it big change? Maybe speaker has narrow bandwidth and plays quieter sounds near the edges... It seems that this module has also capacitor connected parallel to potentiometer - it could make tones of higher frequency quieter (lower impedance of capacitor on high frequences - but I haven't checked its capacitance - it can be too small to make difference for audio)
thx a lot best friend .i don't want how to thank you really.all works well
i share you my rectified program with makecode(this is the microbit language that i teach to our pupils in school)