An easy way to make noise with Arduino using tone()

Поделиться
HTML-код
  • Опубликовано: 14 июл 2024
  • 🤩 FREE Arduino Crash Course 👇👇
    bit.ly/get_Arduino_skills
    **If you like this, I think you'll like the premium Arduino training we offer. Check it out here**
    bit.ly/3nSBPUs
    Click Below to Read About This Topic on Our Website
    programmingelectronics.com/an...
    We designed this circuit board for beginners!
    Kit-On-A-Shield: amzn.to/3lfWClU
    SHOP OUR FAVORITE STUFF! (affiliate links)
    ---------------------------------------------------
    We use Rev Captions for our subtitles
    bit.ly/39trLeB
    Arduino UNO R3:
    Amazon: amzn.to/37eP4ra
    Newegg: bit.ly/3fahas8
    Budget Arduino Kits:
    Amazon:amzn.to/3C0VqsH
    Newegg:bit.ly/3j4tISX
    Multimeter Options:
    Amazon: amzn.to/3rRo3E0
    Newegg: bit.ly/3rJoekA
    Helping Hands:
    Amazon: amzn.to/3C8IYXZ
    Newegg: bit.ly/3fb03X1
    Soldering Stations:
    Amazon: amzn.to/2VawmP4
    Newegg: bit.ly/3BZ6oio
    AFFILIATES & REFERRALS
    ---------------------------------------------------
    ►Audible Plus Free trial: amzn.to/3j5IGrV
    ►Join Honey- Save Money bit.ly/3xmj7rH
    ►Download Glasswire for Free:bit.ly/3iv1fql
    FOLLOW US ELSEWHERE
    ---------------------------------------------------
    Facebook: / programmingelectronics...
    Twitter: / progelecacademy
    Website: www.programmingelectronics.com/
    Do you need to make some noise with Arduino? Maybe a simple tone for an alarm, maybe a beep to alert you when a specific input threshold is met, or maybe to play the Super Mario Brothers soundtrack to entertain your juvenile mind (it’s OK, we are all there too).
    Whatever your audible need, you will likely find the easiest, quickest and possibly the cheapest way to make some noise is using the tone() function and piezo speaker with your Arduino.
    ###This is exactly what you will learn in this lesson:
    1. A quick intro to piezo speakers (aka piezo buzzers)
    2. How to set up a simple piezo speaker circuit
    3. The basics and more of using the tone() function
    4. The limits you should know when using tone()
    ###Hardware You Will Need:
    * Arduino board, I am using an Arduino Uno [1]
    * Solderless breadboard [1]
    * Jumper wire [2]
    * Piezo speaker (aka piezo buzzer) [1]
    * At least 12 cm dental floss, with a thick wax coating (mint flavored works best) [1]
    ###A quick intro to piezo speakers (aka piezo buzzers)
    Ahh noise….
    Birds make it, kids make it - it can be music to our ears or pure torture.
    We are going to use a piezo buzzer to make some noise with Arduino.
    A piezo buzzer is pretty sweet. It’s not like a regular speaker that you might think of. It uses a material that’s _piezoelectric_, it actually changes shape when you apply electricity to it. By adhering a piezo-electric disc to a thin metal plate and then applying electricity, we can bend the metal back and forth, which in turn creates noise.
    The faster you bend the material, the higher the pitch of the noise that’s produced. This rate is called frequency. Again, *the higher the frequency, the higher the pitch of the noise we hear*.
    So basically, by shocking the plate over and over really fast, we can make noise. I don’t know who comes up with this stuff, but they’re friggin’ mean.
    Now let’s set up this circuit.
    ###How to set up a simple piezo speaker circuit using Arduino
    It’s painfully easy to set up a simple piezo speaker circuit with an Arduino.
    1. Place the piezo buzzer into the breadboard so that the two leads are on two separate rows.
    2. Using jumper wires, connect the positive lead to Arduino digital pin 8 and the other lead to any Arduino ground pin. The case of the buzzer may have a positive sign (+) on it to indicate the positive lead (if not, then the red wire usually indicates the positive lead).
    That’s it.
    Let’s go ahead and jump into the Arduino sketch.
    ###The basics and more of using the tone() function
    The tone() function works with two arguments, but can take up to three arguments. Let’s address the two required items first:
    tone( pin number, frequency in hertz);
    1. The pin number that you will use on the Arduino.
    2. The frequency specified in hertz. Hertz are cycles per second.
    The frequency is an unsigned integer and can take a value up to 65,535 - but if you are trying to make tones for the human ear, then values between 2,000 and 5,000 are where our ears are most tuned.
    As an experiment, try changing the second argument in tone() to 100, 1000, 10000, 650000 and listen to the effect it has on the audio signal.
    Read More...
    programmingelectronics.com/an...
    About Us:
    This Arduino tutorial was created by Programming Electronics Academy. We are an education company who seek to help people learn about electronics and programming through the ubiquitous Arduino development board.

Комментарии • 110

  • @programmingelectronics
    @programmingelectronics  3 года назад +1

    ****If you like this, I think you'll like the premium Arduino training we offer. You can check it out here**** bit.ly/3lHyzcB

    • @crypleman
      @crypleman 3 года назад

      i bought larger piezo speaker, is it posible to send pin where tone out to step up module, so my piezo got louder...?

    • @zaidamos1333
      @zaidamos1333 2 года назад

      you all prolly dont care but does anybody know of a method to log back into an Instagram account..?
      I stupidly forgot the login password. I would love any tips you can give me.

  • @acatisfinetoo3018
    @acatisfinetoo3018 4 года назад +66

    My left ear really enjoyed this...but the right one feel left out.

  • @TomBudin
    @TomBudin 8 лет назад +8

    Dude you don't know how much this has helped me

  • @kobedde
    @kobedde 7 лет назад +5

    Nice and clear tutorial. Thanks for this.

  • @sorenstorm
    @sorenstorm 8 лет назад +2

    So nice! Thank you for your calm and thorough walkthrough. Great work ! Really appreciated

    • @sorenstorm
      @sorenstorm 8 лет назад

      +Søren Storm btw - I did the dental floss thing. Really cleaned my teeths

  • @davidbennett7365
    @davidbennett7365 7 лет назад

    you are a fantastic teacher, Awesomely clear...nice work!

  • @JoeSmoeDoeLow
    @JoeSmoeDoeLow 5 лет назад +3

    Thank you for this video. It was really helpful and informative.

  • @roshanwickremasinghe7555
    @roshanwickremasinghe7555 7 лет назад +1

    Thank you very much for sharing your knowledge!

  • @vcguerrilla6438
    @vcguerrilla6438 6 лет назад +5

    My left ear enjoyed the musical tone

  • @rumingjiang9645
    @rumingjiang9645 Год назад +1

    my left ear enjoyed this video very much

  • @sumedhburbure4173
    @sumedhburbure4173 6 лет назад +2

    great presentation skills u got there!

  • @erdoganguner2394
    @erdoganguner2394 2 года назад +1

    This is exactly what I needed for a diy sound wave generator with a buzzer for a school project!
    Also, even though it's mentioned in every comment bellow, great tutorial.

  • @Nykho1409
    @Nykho1409 2 года назад +1

    my left ear enjoyed it !

  • @Blinkation
    @Blinkation 7 лет назад +14

    it's piezo not peizo, great tutorial btw, actually all your tutorials are great i watched them all and learned a lot.

  • @nathanking9771
    @nathanking9771 6 лет назад +1

    Nice job!

  • @py2pw
    @py2pw 4 года назад +1

    Your video helped me a lot, thanks Buddy !

  • @Digitalmannen
    @Digitalmannen 9 лет назад +32

    I only have sound in the left channel on this video, is that done on purpose?

    • @Digitalmannen
      @Digitalmannen 9 лет назад

      ***** i now hear that if I turn the volume way up there is son on the right channel too, but it is very low volume

    • @programmingelectronics
      @programmingelectronics  9 лет назад +2

      ***** That was a production error on my end. I just got some new equipment that I am still figuring out. Shouldn't happen again - but thanks so much for bringing it to my attention!

  • @mehmetcetin2926
    @mehmetcetin2926 7 лет назад

    thaks a lot :) it is great explaining

  • @damithsm1980
    @damithsm1980 6 лет назад +1

    Great ...Thank You.

  • @TheFlybyman
    @TheFlybyman 2 года назад +1

    good explination, thanks!

  • @j0hmama
    @j0hmama 5 лет назад +1

    you had me with dive bar.
    I liked the inclusion of limitations, and the annotation to explore erroneous sounds. perhaps a video response is in order.

  • @codybattery8370
    @codybattery8370 8 лет назад +1

    thanks man

  • @yousaftoki1599
    @yousaftoki1599 Год назад

    Amazing knowledge sir...

  • @link9k
    @link9k 3 года назад +1

    great material! thanks for showing this! Appreciate your research on all specific details of the tone fn

  • @omkarkhade4602
    @omkarkhade4602 4 года назад +1

    Great video..

  • @nazranzafran3807
    @nazranzafran3807 4 года назад +1

    Thx

  • @robink.9459
    @robink.9459 6 лет назад +3

    4:23 "One Hert" ... lmao

  • @ESEG-bs1yp
    @ESEG-bs1yp 8 лет назад

    well..I used passive buzzer but I don't if it's better than peizo buzzer.
    Thank u very much, u helped me :)

  • @centillion1684
    @centillion1684 2 месяца назад +1

    Thank you

  • @captainkaveh1
    @captainkaveh1 6 лет назад +1

    Great Thank you, please upload a video how to create a sound like car horn sound.

  • @michaelcostello6991
    @michaelcostello6991 2 года назад +1

    Could this be used for anti dog barking at 20KHz . What speaker/buzzer would be best for this ? What sound in db can it create

  • @GanisChannel24
    @GanisChannel24 2 года назад +2

    New subscriber♥️

  • @discoHR
    @discoHR 5 лет назад +1

    Is there any tool out there which coverts an audio sample to an array of frequency-duration pairs for use with the tone function?

  • @someonetyping
    @someonetyping 7 лет назад

    I've tried creating a pushbutton synth using the tone function, but the tone only seemed to play after releasing the pushbutton. Is there any way around this?

  • @AtomkeySinclair
    @AtomkeySinclair 7 лет назад

    Do this:
    tone(peizoPin, 3000);
    delay(100);
    noTone(); [or what about tone(peizoPin, 0);] immediately turn off the tone
    delay(1000); [and now your tone doesn't overlap into the delay]
    So write a class/method or function called beeper(int pinout, int hz, int Tdelay);
    {
    tone(pinout, hz);
    delay(Tdelay);
    noTone();
    }
    - cheers -
    Now you can oscillate the oscillator so to speak without time corrections having
    to be calculated inline every single time you make the call to tone.

  • @rickmorenojr
    @rickmorenojr 6 лет назад +1

    Great video. The video voiceover is only on the left speaker.

  • @RanaRao_Chandrachur
    @RanaRao_Chandrachur Год назад +1

    *Best tutorial ever on the earth!!*
    BTW can u make the Chinese Cuckoo clock tone using Arduino?? 🙂 Because of how to make that "vintage Bell" sound and also the birds sound at the same time, I'm just confused, I mean the coding.. .🙂 I mean how I will know what frequency tone will be on for what seconds to generate the cuckoo sound?? that is my question!!

  • @Jared-vq8qg
    @Jared-vq8qg 8 лет назад

    Is their any way to have more than one speaker playing at the same time when your using ultrasonic speakers. I think I have seen someone do something similar to that before, but I am not sure what steps they did to get to that result.

  • @fbravo8686
    @fbravo8686 9 лет назад +1

    Nice! ..

  • @MyOwntuahur
    @MyOwntuahur 5 лет назад

    nice

  • @ComandanteJ
    @ComandanteJ 7 лет назад

    Does tone() work with regular "PC Speaker" .5w 8 Ohm speakers too? I guess it would be much quieter if it does...

  • @cadillacescalade5428
    @cadillacescalade5428 3 месяца назад

    Hi, could I use this for a bell sound with a 8ohm speaker?

  • @gekkougagrentninja6837
    @gekkougagrentninja6837 5 лет назад

    I need help please :(( I am trying this for my project. I already made a sketch for the piezo buzzer's sound but when I tried it with a 9V Battery, the patter doesn't work? Is there a way for it to work in 9V Batteries? Please I need help :((

  • @nirmalgurukothandaraman8200
    @nirmalgurukothandaraman8200 5 лет назад

    Sir can you help me in choosing resistors in circuit how to determine the ohms

  • @sabrroemma
    @sabrroemma 3 года назад

    Dude im a german and i Unterstand it, pretty giod

  • @cadillacescalade5428
    @cadillacescalade5428 2 года назад

    Anyway that I could get a bell sound like a railroad crossing sound ?

  • @hindalkanderi3122
    @hindalkanderi3122 7 лет назад

    Hi!
    How can I make Arduino play a music note or a song?

  • @andreamitchell4758
    @andreamitchell4758 6 лет назад

    ok but how do we make it useful? say i want to use keypad and have it emit a tone every time a key is pressed and not have the code interfere with the rest of the code?
    i am trying to make a garage door keypad with a keypad and relay and 2 LED's
    i want the pad to emit a tone every time a key is pressed and another tone if the code is wrong and yet another tone if it is wrong

  • @shashankbhatta9786
    @shashankbhatta9786 4 года назад

    are these buzzers waterproof?
    I want to use tham as mist maker by emitting ultrasonic sound.

  • @thesloable
    @thesloable 8 лет назад +1

    I'm following along your tutorials and I noticed that resistors were used in different ways. Sometimes voltage passing through, sometimes one end goes to the GND and sometimes one end is interrupting the flow and the other end goes to the GND. Is there any guideline/tutorial on how to use resistors in what kind of situation? Thanks.

    • @3dw3dw
      @3dw3dw 8 лет назад

      Nice observation.
      it depends on what you are trying to accomplish.
      if you are using the resistor to limit current it will be in series with the load (like an led).
      otherwise it may be used as a pull up resistor to tie a pin to positive voltage or a pull down to tie a pin to ground ( used with buttons and switches to avoid pin float irregularities ).
      you should invest more in studying use of resistors. there are many clever tricks you will learn.

  • @SemlerPDX
    @SemlerPDX 5 лет назад

    "An easy way to make noise in the left audio channel when rendering a tutorial video" ;) Pro-Tip: assuming you already send your windows audio through a pro mixer like VoiceMeeter Potato -- tell the audio stream it's Mono, and it'll come out of both ears. Cheers!

  • @noob-killer
    @noob-killer 6 месяцев назад

    im using tone() without using pin 3 and 11, yet it still creates artifacts (the buzzer makes noise while not activated with tone(), and my led matrix's lights are dimmer and flicker at times). how to fix???

  • @adilabusafa
    @adilabusafa 4 года назад +1

    أهلا وسهلا ومرحبا.

  • @shashankbhatta9786
    @shashankbhatta9786 4 года назад

    which model of piezo buzzer is that?

  • @diegop-s7943
    @diegop-s7943 6 лет назад +5

    What about the dental floss?

  • @bagyofficial1083
    @bagyofficial1083 7 лет назад

    Hello.Can you help me?I have some problem.When I write :
    tone(peizoPin, 3000)
    and push verify button the aplication write to me :
    "tone"was not declared in this scope
    Can you help me?

  • @BlazeTheCatMan
    @BlazeTheCatMan 3 года назад

    how do i use the random function with it? can you give help? :)

  • @iltonrotta
    @iltonrotta 3 года назад

    Can I use it to stop dog barking? thanks

  • @JimiTip
    @JimiTip 5 лет назад

    Is the intro song an actual full length song? If so whats the name? Thanks

    • @programmingelectronics
      @programmingelectronics  5 лет назад +1

      The attribution link is at the end of the video. It was a remix of those tracks.

    • @JimiTip
      @JimiTip 5 лет назад +1

      @@programmingelectronics thanks!

  • @andyhughes800
    @andyhughes800 7 лет назад

    how do i add a push button to this to make the tone start and stop when i want?

  • @MyBigThing2010
    @MyBigThing2010 7 лет назад

    just did this...super EASY! ...now my dog is pissed at me though haha

  • @razelldeguzman4176
    @razelldeguzman4176 8 лет назад +2

    i dont have 220 ohm resistor, can i use 560 ohm resistor?

  • @bobogao6328
    @bobogao6328 5 лет назад

    Hi, i tried the same code and same pin. But duration does not work. I tried many times with different pins .please help!

  • @wantafastz28
    @wantafastz28 5 лет назад

    Is there any way to make it do sound, instead of a tone? Such as saying the letter A, over and over again?

  • @shashankbhatta9786
    @shashankbhatta9786 4 года назад

    waht happens if we dont use resistor?

  • @daletappy9327
    @daletappy9327 7 лет назад

    what frequency should i put to make a BUZZ sound?

    • @colewood8288
      @colewood8288 6 лет назад

      You need to sweep at a high frequency.
      For example: 800-1000Hz @ 120Hz will generate a buzz.

  • @abhaykondru3570
    @abhaykondru3570 3 года назад

    sir i used tone parameter its not working i mean iam not getting delay help me out sir please

  • @apinakapinastorba
    @apinakapinastorba 7 лет назад +1

    "One hert" :D

  • @anonymoususer900
    @anonymoususer900 3 года назад

    audio is only in left earphone and my earphones are not broken XD

  • @rabbythebeat
    @rabbythebeat 6 лет назад +1

    how to make sound like ambulance siren using tone function

    • @IoTLearner
      @IoTLearner 6 лет назад +1

      TRY THIS BRO :)
      void setup() {
      }
      void high(){
      for(int i=1000;i=1000;i--)
      tone(11,i,1000);
      delay(10);
      }
      void loop(){
      high();
      low();
      }

  • @kyleabril3856
    @kyleabril3856 4 года назад

    Does it work on nano?

  • @Anton-sz6ef
    @Anton-sz6ef 5 лет назад

    Am I the only one that didn't knew that this even existed ?

  • @j0hmama
    @j0hmama 5 лет назад +1

    how can I make notes?

  • @jono5891
    @jono5891 3 года назад +1

    what is the dental floss for I'm so confused

  • @mother-fng-bonswa3612
    @mother-fng-bonswa3612 6 лет назад

    why they didn't call it freq ..

  • @nikoslykouresis2275
    @nikoslykouresis2275 4 года назад +1

    int piezoPin = 8;
    int del = 1000;
    void loop() {
    tone(piezoPin, 2500, 200);
    delay(del);
    del -= 20;
    }
    ...💥💥💥

  • @lioraharoni5747
    @lioraharoni5747 4 года назад

    Man this is just so annoying that the sound of this video is Mino. It really hearts my ears.

  • @franctiekam3008
    @franctiekam3008 Год назад +1

    mississippi😂

  • @ayoubsbai6339
    @ayoubsbai6339 3 года назад

    MAKE SOME NOISE, PUT YOUR HANDS UP IN THE AIR!!

  • @rupe82
    @rupe82 3 года назад

    I have tinnitus that sounds like an 8800 tone.

  • @planktonfun1
    @planktonfun1 3 года назад

    2020 its not fantastic :(

  • @MikevomMars
    @MikevomMars 3 года назад

    My neighbours are breeders. Their children make enough noise 😑

  • @pacifiqueniyonkuru8447
    @pacifiqueniyonkuru8447 2 года назад

    Hello can you give your email?

  • @MyBigThing2010
    @MyBigThing2010 7 лет назад

    just did this...super EASY! ...now my dog is pissed at me though haha