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 6310 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

    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
Reply
  • 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
Children
No Data
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