element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum circuit connexion of potentiometer and external speaker
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 44 replies
  • Subscribers 386 subscribers
  • Views 6306 views
  • Users 0 members are here
Related

circuit connexion of potentiometer and external speaker

naimlion
naimlion over 2 years ago

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

  • Sign in to reply
  • Cancel

Top Replies

  • shabaz
    shabaz over 2 years ago in reply to naimlion +3
    Hi, There's just two or three wires on the potentiometer. I strongly suggest you just wire it up (in any way you think fit, you can google this), and see what happens. You'll learn more from that experience…
  • JWx
    JWx over 2 years ago in reply to phoenixcomm +2
    In the end it turned out that it was software task - potentiometer was supposed to drive software based volume control, which the author finally achieved...
  • shabaz
    shabaz over 2 years ago in reply to naimlion +1
    Hi, You're not bothering me, this is genuinely the best advice I can think of. It's the best way to learn, just to try it, because in this particular instance, you're very unlikely to damage anything…
Parents
  • JWx
    JWx over 2 years ago

    What sort of speaker? Dynamic one can overload arduino pin if connected directly - it can have several ohm resistance (so series connected potentiometer can help limiting current, if never set to zero) - better add additional resistor in series so max. current draw from the pin will not exceed MCU limits...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • naimlion
    naimlion over 2 years ago in reply to JWx

    hi again

    i have this one

    www.google.com/url

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • JWx
    JWx over 2 years ago in reply to JWx

    like this (but without capacitor) - as I have written previously - exactly like potentiometer that is at module's input (you can checkk schematics on the page you have provided):

    module schematic's fragment

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • naimlion
    naimlion over 2 years ago in reply to JWx

    i telled you that the speaker works good so the blue knob is not set to zero  yes or no.

    please can you send me a circuit picture to describe connections

    please i have trouble in : where i connect out pin of potentiometer?

    where i connect sig pin of speaker and also vcc pin of speaker

    yours trully

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • naimlion
    naimlion over 2 years ago in reply to JWx

    so i understand that i connect out pin of potentiometer to sig pin of speaker?

    yes?   or to vcc pin of speaker that´s exactly what i search 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • JWx
    JWx over 2 years ago in reply to naimlion

    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?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • naimlion
    naimlion over 2 years ago in reply to JWx

    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

    makecode.microbit.org/_JKPMof632HH7

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • JWx
    JWx over 2 years ago in reply to naimlion

    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)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • JWx
    JWx over 2 years ago in reply to JWx

    I think you are not doing what you thin you are doing:

    basic.forever(function () {
        pot = pins.analogReadPin(AnalogPin.P2)
        pins.analogWritePin(AnalogPin.P1, pot)
        music.playSoundEffect(music.createSoundEffect(WaveShape.Sine, 5000, 0, 255, 0, 500, SoundExpressionEffect.None, InterpolationCurve.Linear), SoundExpressionPlayMode.UntilDone)
    })

    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

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • JWx
    JWx over 2 years ago in reply to JWx

    have you tried putting pot value to

    music.setVolume(pot)

    playSoundEffect doesn't have volume variable but setVolume may set i globally (maybe)?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • naimlion
    naimlion over 2 years ago in reply to JWx

    it works now but look to my code that  just i used play ton ...bloc and not melody but me i want to play melody and change sound volume

    here i share my makecode code and my circuit image

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • JWx
    JWx over 2 years ago in reply to naimlion

    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?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • JWx
    JWx over 2 years ago in reply to naimlion

    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?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • JWx
    JWx over 2 years ago in reply to JWx

    there is possibility that microbit library doesn't allow for changing volume of sound played by playSound() - in this case analog version (pot between micorbit and speaker module) would do the trick...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • naimlion
    naimlion over 2 years ago in reply to JWx

    https://makecode.microbit.org/_7WM2Hdhbfat8

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • JWx
    JWx over 2 years ago in reply to naimlion

    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)

    let pot = 0
    basic.showIcon(IconNames.Heart)
    music.setBuiltInSpeakerEnabled(false)
    pins.setAudioPin(AnalogPin.P1)
    basic.forever(function () {
        pot = pins.analogReadPin(AnalogPin.P2)
        music.playTone(pot, music.beat(BeatFraction.Whole))
    })

    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

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • naimlion
    naimlion over 2 years ago in reply to JWx

    thx a lot i will try but i want to ask you why when i changed frequency the volume changed also

    is it the same thing?

    regards

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • JWx
    JWx over 2 years ago in reply to naimlion

    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)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • naimlion
    naimlion over 2 years ago in reply to JWx

    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)

    makecode.microbit.org/_imoEThioYhoC

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • naimlion
    naimlion over 2 years ago in reply to JWx

    now after we solved this and all works well.i have a question:can we use microbit speaker  at the place of external speaker and can we change volume by potentiometer?

    yours truly

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • JWx
    JWx over 2 years ago in reply to naimlion

    glad to help!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • JWx
    JWx over 2 years ago in reply to naimlion

    I think it will work the same - simply remove disabling internal speaker and setting external audio pin...

    so - remove:

    music.setBuiltInSpeakerEnabled(false)
    pins.setAudioPin(AnalogPin.P1)

    and check if it will suffice

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • naimlion
    naimlion over 2 years ago in reply to JWx

    how to be in touch with you really you are good person

    email,fb,...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube