Тёмный

Arduino Tutorial 24: Understanding Passive Buzzers 

Paul McWhorter
Подписаться 385 тыс.
Просмотров 137 тыс.
50% 1

Опубликовано:

 

17 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 407   
@borymcpherson9759
@borymcpherson9759 4 года назад
Boy I had a hard time with this session! I am 71 years old and about half deaf and I could just barely hear any of the tones from the passive buzzer. I just kinda had to take your word for this one. Hope I can do better on the next lesson. I am really enjoying have somethinge to do while being shut-up in my house, due to this virus. Thanks for your time and effort!
@BRP42
@BRP42 3 года назад
The pickup on the microphone wasn’t great.
@arlo4051
@arlo4051 3 года назад
Consider yourself lucky, with Tinnitus I get to hear the passive buzzer full volume, 24/7, with it turned off, in a drawer. As for the buzzer on the bread board can't get it loud enough to hear over the one in my head.
@ayushmanjain4008
@ayushmanjain4008 3 года назад
Just slightly touch the buzzer and do not cover the top. You would be able to feel the tone
@MaxRelativo
@MaxRelativo 3 года назад
Congrats, Bory! I think most of the guys of your age should be so pro-active!
@frankswift5119
@frankswift5119 3 года назад
I'm in my seventy's and I cannot hear any of the sounds but my wife can.
@Sheredo
@Sheredo 10 месяцев назад
Hi Paul, great lesson as always! In case someone, like me, is watching only now, 2 things: 1) Just to make sure I did the equation correctly, I printed the value of both my tone and my potval, exptecting that: -If potval=0, then tone=60. -if potval=1023, then tone=10.000 Initially I had problems 'cause when potval was equal to 1023, my tone was something like 9.670 Then I realized that I set the tone as an INT instead of a FLOAT! In the video you did the same, but withot the serial monitor I think you didn't realize this. Changing the tone into a FLOAT made everything right. 2) Even though my math was correct, the tone I was hearing seemed a lot different than yours. I discovered that it was due the serial.print I put in the code. Reading the comments of this video, I discovered that I could keep the print if I changed the baud rate of the serial monitor into something higher! (1.000.000 was the minimum to not have distortion).
@simpjkee
@simpjkee 5 месяцев назад
I was having all these issues as well.
@simpjkee
@simpjkee 5 месяцев назад
I tried this again tonight. With the higher baud rate it sounds much better, but it still sounds very distorted for me. It sounds like something an experimental prog rock band would do like Pink Floyd or something. It's doesn't sound anything like a tone a flute or something would make.
@MarvelBi
@MarvelBi 5 месяцев назад
Dude thank you so much I thought it was just ne
@tashadurrahman
@tashadurrahman 4 года назад
I did the the homework assignment and it went perfectly well! YAAYYYYY!
@dancorwin9232
@dancorwin9232 2 года назад
Hey paul! Really loving this series. I'm not sure if your musically inclined at all, but as a musician myself is trying to get into electrical engineering, the reason those first few buzzes you were making "sound like music notes" as you put it is because they actually ARE musical notes! When you were tinkering around with the delay time and setting it fro my 1ms to 2ms and 3ms and so on, you are actually creating what's called an Overtone Series of notes! It's one of the fundamental Bridges between sound waves and our modern understanding of music. You may have already known this, but I figured I would point it out as a shout out to any other musically inclined engineers!
@236Doodad
@236Doodad 3 года назад
1:11 It's actually silicone dielectric potting and not black tape on the bottom of the active buzzer. Only pointing this out in case someone wants to know this; I'm not just being a pedantic jerk for the sake of it. Loving the series so far, I've learned so much.
@MardinBodley
@MardinBodley 2 месяца назад
Paul you are brilliant and I went way over the top with the homework built a 9 button tactile switch keyboard in the key of A. Icalculated for major triads for A D and E major 3 rows for A C# and E 2nd row D F#.... and E G A microsecond delay off 2240 for A . So C# delay for mark and space would be 12th root of 2 = 1.0596 raised to the power of 4 and inverted and multiplied by 2240. The idea of for this concept came from 1976 when a guitar student built a guitar but equally spaced the frets 1 inch apart absolutely unplayable. I did not know the equation. He was not happy and smashed the guitar to pieces outside my flat. Well move forward to 2019 and I solved the conundrum (from first principles without using the internet) as above but instead of 2240 delay. The 4th fret position of A is string length is 25 inches x 1/ (12th root of 2 raised to the power of 4 x 110 hz )
@m00se22
@m00se22 4 года назад
I was able to make a little alarm and authentication circuit depending on whether the user enters a correct password or not using the serial monitor. Thanks for putting this information out there! With what I've learned from you, I feel comfortable taking on my own projects more so than before with Arduino.
@gilnasty82
@gilnasty82 2 года назад
Math has never been my strongest skill! But after playing with this circuit and tweaking the formula numerous times, I have a much better understanding of what's happening! Thanks Paul!!
@RahulMishra-ov4nr
@RahulMishra-ov4nr 2 года назад
This is the first time I didn't do the project on my own but later realized I could've done it if I tried harder. Great videos keep up the good work.
@simontopley4771
@simontopley4771 11 месяцев назад
Confess, i did struggle with this one somewhat, i get stuck on the maths, working out these formulae at my age isn't so easy. Thanks again.
@426F6F
@426F6F Год назад
That formula took me like 10 mins to work out on my own 😅 I like this form of logical thinking though, it's good practice!
@octogintillion
@octogintillion Год назад
I got the formula right, but I did it way less elegantly. 😅The way I thought it out is that you have to go from potVal=0 to tone=60, and the only way to do that is to add 60 to 0. Then if you would continue with the 10000/1023 like we did previously to get tone=10,000 for potVal=1023, you would actually end up with 10060 since you added 60 before. So I just subtracted 60 from 10,000 to get the value to divide by 1023. I love that you show the "right" way to solve problems like this! Keep up the great work.
@henderic0
@henderic0 3 года назад
Those beeping noises made my bird go absolutely bonkers 😅.
@itimariu
@itimariu Месяц назад
Heh, I was joking that I built a cat-waker-up'er.
@kananabdlyv
@kananabdlyv Год назад
Mr.McWhorter I am very thankful that your channel popped up in my RU-vid recommendations. I was looking for a good Arduino teacher, and in a short period of time I found you. Although I had a great experience with programming before learning Arduino, your videos really helped me to actually visualize the process happening behind my code. I carefully listen to your homeworks, and more importantly, do not cheat :) I especially liked this lesson's homework (very enjoyable). Thank you for everything so far.
@kananabdlyv
@kananabdlyv Год назад
Also thanks for liking my comment 🙏
@S24W2
@S24W2 Год назад
Me too 😊
@rakowumusic5143
@rakowumusic5143 2 года назад
Such a great content. I have already learned so much about the circuits. For those who like to make music :) int outPin1 = 13; int c = 472; int d = 420; int e = 375; int f = 353; int g = 315; int a = 280; int b = 249; //delay int dt = 100; int minim = 2000; int crotchet = 1000; int quaver = 500; int semiquaver = 250; void setup() { pinMode(outPin1,OUTPUT); } void note(int duration,int note,int pause){ for(int i=0;i
@rakowumusic5143
@rakowumusic5143 2 года назад
(I have also made pirates of the caribbean :D)
@XHuang-hv5cj
@XHuang-hv5cj 2 года назад
Nice work! how long did this take you?
@itimariu
@itimariu Месяц назад
Thank you :) I downloaded and tried it.
@StefanEckhardt-y6r
@StefanEckhardt-y6r Год назад
Hello Paul, I tried the excercise on my own, as you recommended....but got a difference in solving the excercise. You said....if you turn the potentiometer to the left, have a delay of 10.000 microseconds....to the right 60 microseconds? Right? If yes, to the potentiometer to the left will return a potValue of 0. So the combination of x and y will be: if the potValue will be zero, the delay should be 10.000 microseconds...and vice versa to the right....potValue 1023 will return a delay of 60. The equation will then be different: y=-9,7165+10.000. If I misunderstood your instructions....nonetheless a big thanks, because the result was: I LEARNED IT!! Best regards!
@jstro-hobbytech
@jstro-hobbytech 3 года назад
figured it out! most personally rewarding lesson yet. thank you so much Paul, you have no idea what these classes are doing for my mental health.
@paulmcwhorter
@paulmcwhorter 3 года назад
Actually, it is incredibly good for mental health to create something. Build something, grow something, cook something, make something. All incredibly healthy. I think a lot of people on lock down are binging on Netflix, silly cat videos, and inappropriate internet content, and really think it is driving people into depression and mental illness.
@robertnelson1802
@robertnelson1802 4 года назад
I used variable for buzzH, buzzL, potH & potL (all integers adn it still seemed to work) then used a variable based equation. I also put print statements in the loop but had to take them out as they were causing the tone generator to just click. Took me a little while to realise that it was the print statements that were doing that. Keep up the great work - loving the course.
@JohnB-r6c
@JohnB-r6c Год назад
Wondering why with a delay after the print code (Serial.print(); with delay after creates only clicks?? Without delay, no clicks! delays of 500, and 1000 ms. the clicks occur.
@Японскийшагзашагом
Thank you very much for the great lesson! I did the assignment using if statements in the beginning, and I am ashamed to admit, that I watched the beginning of the homework explanation before finishing it on my own. I will work on my math! Thank you very much again, you are a true inspiration, and I am so happy to learn from you. All the best!
@paulmcwhorter
@paulmcwhorter Год назад
Excellent!
@Anonymous-yy5qr
@Anonymous-yy5qr 3 года назад
The satisfaction that I get after doing your assignment without your help is immeasurable ❤️
@hasan-motam
@hasan-motam Год назад
This assignment helped me to understand passive buzzers. Thanks Paul.
@TMRu22311
@TMRu22311 3 года назад
This was a fun lesson, reminded me of the "Library Tormentor" project I did in high school many years ago (1986). I added a switch to the buzzer to turn it on/off and my cats thanked me for it :D
@jasonbrown2674
@jasonbrown2674 Год назад
I got it! Amazed myself. Thanks Paul, great lesson 👍
@paulmcwhorter
@paulmcwhorter Год назад
Great job!
@muhammadrafiqulislamkhan6994
@muhammadrafiqulislamkhan6994 3 года назад
Few day I busy with my room construction resetup that is why I can not attend your lesson but I am back. And would say you are a Messaih for me. I do not understand why I understand your all words so easily. What is the reason? I have tried another Arduino video but as you no one for me. You are a perfect teacher. Day after day overwhemingly I just watch and learn from you. You are such a kind teacher. Thanks for you. God bless you.
@the_real_sauce_boss
@the_real_sauce_boss 2 года назад
This was my favorite lesson so far, I struggled trying to make sure that the delaytime never dropped below 60, but the coffee helped me get through it! Thank you so much for these videos, they make it so much easier for beginners like me to learn. I enjoy them so much I spent 8 hours watching your videos yesterday!
@paulmcwhorter
@paulmcwhorter 2 года назад
Great job!
@erikburman530
@erikburman530 2 года назад
Holy Moly! At 61 years of age this is the first time since high school algebra that I've truly understood how to apply the equation for a straight line. That sad little equation has been lying dormant in some cobwebbed recess of my mind until today.
@paulrockwell9914
@paulrockwell9914 3 года назад
I'm an experienced software guy (dusting off some long-dormant C coding) making the foray into circuits and microcontrollers now that I'm retired. Nice progression from the relatively short lesson 23 to lesson 24 with the passive buzzer. Love it when lessons have a logical progression.
@damonbostrom6857
@damonbostrom6857 8 месяцев назад
I'm really getting a lot out of this series! I've worked through each tutorial so far. Thank you for producing this class! I hope that you will cover midi compliance eventually.
@danwolfe7665
@danwolfe7665 3 года назад
Loved the homework assignment, really made me think and do a little math. I did it opposite mathmatically so my equation was Y=-9.7165(X)+10000
@brightenpeer1356
@brightenpeer1356 8 месяцев назад
I did that, too!
@CarolMartinYoutuable
@CarolMartinYoutuable 2 года назад
Math has always been a weak point for me but thanks to your lessons, I've been able to do this. I was able to do the homework without any help other than the comments below when I didn't get the right tones because of the print statements in my code and the low baud rate. When I removed the print statements (or at least narrowed them to one print statement) it all worked beautifully. Thanks again Paul
@njsk8rdan
@njsk8rdan Год назад
I am having fun going along with these videos. When you said "that's annoying I am going to unplug it" I said "that's why I added a 'while(potVal>1000)' statement. Wanted to make sure I could get to somewhere on the potentiometer where it wouldn't make any sound. 🤣
@carlos2004
@carlos2004 4 года назад
for anyone doing the Serial.println(potVal) command, i think it messes up the timing for the tones. even when using numbers and not using the potVal, i couldn't get mine to work. but as soon as i deleted the println command, the tones worked perfectly with value, and the potVal.
@mengkin5836
@mengkin5836 4 года назад
heyy, i had this problem too and i found out its due to the baud rate, as you increase the baud rate the sound will get better, i was shocked too when i finally found out
@TheKverbeeck
@TheKverbeeck 4 года назад
Thank you Meng and Carlos, that solved the issue i had. Printing more text (data) per line deforms the tones even more. String msg = "Delay (Tone) is: "; Serial.println(msg + buzzTimepot); So i changed the baudrate to 2000000 and now all is well.
@joeb.fromsydneyaustralia5313
@joeb.fromsydneyaustralia5313 4 года назад
I had the same problem... getting rid of the Serial fixed it.
@trakeC
@trakeC 4 года назад
I had the same issue. And just fyi instead of deleting your code just go through and add // in front of the lines of code you are unsure about instead of deleting it. That will make it a note and not part of the process. This way you can verify an action before fully acting on it. It's a common practice in code troubleshooting. Other languages have different commands but in this case its //
@chrisjohnson6765
@chrisjohnson6765 3 года назад
A good debugging process for this is to use the // comment lines in front of the suspect line to test it without deleting it.
@dubrocadidier4583
@dubrocadidier4583 2 года назад
This was fun . I had the mathematics right but was confused between the delay and delayMicroseconds. It is NOW clear from your explanations . Thanks Paul , you are a blessing .
@charless704
@charless704 3 года назад
Paul, @ 9:45, you said when the potentiometer is turned to the left the delay is 10,000 microsecond delay, and when turned to the right it is a 60 microsecond delay. I believe your linear equation is flipped, if you will. Obviously, it still works, just with the tone changing backwards as originally described. Love the videos. Nice work
@danwolfe7665
@danwolfe7665 3 года назад
I thought the same thing Charles.
@revupreview
@revupreview 3 года назад
@@danwolfe7665 Me too.
@brightenpeer1356
@brightenpeer1356 8 месяцев назад
Me too!
@michaeljenkins2345
@michaeljenkins2345 3 года назад
The Elego kit is a wonder in packing engineering and a physical paradox all in one! Items are packed so full of stuff and yet so neatly, but once you remove items, you'll never get them all back in the way it was. I have used a separate tool tray that is now full, as well as the Elego kit tray which is somehow still full! Mind blown!
@matthewgroves3671
@matthewgroves3671 Год назад
hi Paul is there any learning resources you can recommend that will help with the maths and calculating the line etc I'm really struggling with understanding it, had to cheat and copy 🙄
@marcovichcamposilva4082
@marcovichcamposilva4082 3 года назад
Thank you very much mr. Paul. i`ve been watching your lessons the way i even dream about arduino,really. i failed in this homework, thats the path to knoledge. I wish the best for you and those who love you.
@stefannilsson7692
@stefannilsson7692 7 месяцев назад
Thanks for the good examples with different calculations. They help very well. Thank you very much for that
@jdecker9834
@jdecker9834 2 месяца назад
Another great lesson Paul! As for the tone pitch, I think the frequency you hear should be 1/(2 * toneVal). Since you're basically creating a square wave to drive the buzzer and your toneVal is the time for half of 1 cycle, then 2 * your toneVal equals the period of your waveform (time of 1 cycle). The inverse of the period is the frequency. It would be cool to put an o-scope on your buzzPin to verify the frequency.
@techbymo
@techbymo 2 года назад
I hadn't done math in a long time and this homework assignment shook some rust off of my brain but glad I could do it on my own with some minor issues haha
@hedgewicksattempts
@hedgewicksattempts Год назад
Banging my head against the wall on this homework for a bit, just getting a clicking sound out of my buzzer. Ended up boosting the baud to 115200 and now it's working great! Time to unpause and see how you made this!
@hedgewicksattempts
@hedgewicksattempts Год назад
Maybe it's because I was printing my values in the Serial Monitor at the same time?
@paulmcwhorter
@paulmcwhorter Год назад
Yes that will throw off the timing.
@dannycollins5698
@dannycollins5698 Год назад
Interesting sounds with this one.
@ijlie
@ijlie 3 года назад
Hi Paul, combined tutorial 18 and this one to have the buzz time asked for in the serial monitor. Gave me fast interaction and saved some upload time.
@johndavid360
@johndavid360 3 года назад
Even though I don’t have a passive buzzer I’m still going to watch this video for consistency!
@jasonford1
@jasonford1 4 года назад
For extra credit, I looked up the tone() function and discovered it ranges from 31Hz to 4978Hz. I plotted tone on the y-axis and potentiometer values of 0 to 1023 on the x-axis. I then used y=mx+b to convert the potentiometer signal to a tone between 31Hz and 4978Hz with one exception. I made 31Hz == noTone(). Now my ears can rest! Time to pause having completed 19-24 and 48/49 today. It has been a great day of learning! I look forward to photoresistors and photodetectors next.
@krishamsub.subedichhetri5895
@krishamsub.subedichhetri5895 3 года назад
I think instead of digital write if we analogwrite we can also use a potentiometer to vary the loudness of the buzzer, because the higher the voltage/Amplitude the louder the sound.
@berlinjackson1847
@berlinjackson1847 4 месяца назад
I just turned 71 also. Im with you on that
@InfectedCreations
@InfectedCreations 3 года назад
If you try this don,t print anything to your serial monitor because this has influence on your tone. ✌👍 Another great tutorial. Boom.😊🤣
@jaytea23
@jaytea23 Год назад
Great lesson as always! One minor thing, you switched the delay times from what you told us in the homework. So you wanted us to have a delay of 10,000 microseconds when potVal is 0, and 60 microseconds when potVal is 1023. So the equation would be a little different: y= (-9940/1023)x + 10,000
@randallg.bennett3695
@randallg.bennett3695 3 года назад
Hi again Paul, Thank you for the lesson, it made sense, and I did need your help (a bit) after the lesson and before the code writing, but it all made sense after I watched you perform the functions. Much appreciated!
@theknottyworkshopgeoffjung529
@theknottyworkshopgeoffjung529 4 года назад
Paul, I believe that you ask that the 10,000 mS tome (lowest) be on the left and the 60 mS (highest ) be on the right. This would make the equation a negative 9940 or change the polarity of the pot.
@revupreview
@revupreview 3 года назад
Yep, that's what he did. But I still got it working even though my formula is a bit different: potVal = analogRead(potPin); // Get potentiometer value. buzzVal = (1023.0 - potVal) * (9940.0 / 1023.0) + 60.0; // Calculate delay time in microseconds. soundTone(buzzVal); // Make a sound. (I wrote a simple soundTone function to make the sound.)
@stevemorgan3597
@stevemorgan3597 4 года назад
Hi Paul. I like the way you teach. Good explanations and visuals. I learned a long time ago in calculus courses to draw diagrams and graphs because it helps with the math. Once the formulas are determined, it makes the programming so much easier. Thanks for all you do.
@robjameson7965
@robjameson7965 4 года назад
'Passive', the "BLUE LED" of the buzzer world! Todays a special day! : )
@alanford7933
@alanford7933 3 года назад
Really good. I used Serial.println (with the good old trusty 9600 Baud rate) and realized that I was not starting at 60. Then went back and included it. Good to do the homework and pick up own mistakes.
@hussambarodi8014
@hussambarodi8014 4 года назад
Very nice, very simple and very easy. Even I learned programming since 30 years, but I am ready to leave everything behind me and go forward for Arduino with Mr. Paul. Thank you Sir, and your students are really lucky. If you allow me to suggest, or maybe request, something. I am not sure if you keep the examples that you made saved in your computer or not, and if so, I hope if you can share them with us. It was my fault that I did not write since the first lesson, and now after I completed 24 lessons, I am unable to go back and check them all, why, because I am thirsty for more and more lessons
@Dieselfitter01
@Dieselfitter01 5 лет назад
Fantastic lesson on the passive buzzer. So much can be the influence on the buzzer with this kit. Oh BTW my AI parts started to arrive today, through your links that is. Case with fan, Micro card, Jetson Nano, Pi Camera, 110 power supply and the WiFi. I am expecting the Webcam tomorrow. The wireless keyboard and mouse were too far off for me to wait for so I will try what I already have and if that fails I will hit the local store. This AI Project is something I think everyone here would be interested in. Great content as always and look foreword to whats in store next.
@paulmcwhorter
@paulmcwhorter 5 лет назад
I will admit I have been pulling my hair out on the nano the last couple of weeks, and almost ready to give up, but think I got some stuff figured out today. Bleeding edge technology which means it is not all figured out yet. Really want to do a series on this now. I have gotten some pretty cool things going now.
@ianneill9188
@ianneill9188 4 года назад
Ok, I am a bit late to the game here, but I really enjoyed this lesson. I think the repeat line graph math refresher was super. Many thanks for your diligence and time.
@davidransier
@davidransier Год назад
I struggled a bit with this lesson. It turns out that I had three Serial.Print statements to help debug the resistor value versus the Buzzer timer value. I was outputting 60-10000 microseconds properly but it sounded awful - then I removed the print statements and all was good. Those dang print statements are s-l-o-www! It was a good debugging exercise!
@paulmcwhorter
@paulmcwhorter Год назад
Yes print statements are really slow and will affect your timing on things.
@lloydbotway5930
@lloydbotway5930 3 года назад
This works quite well. More fun: check out the tone() function, which does much of this automatically.
@426F6F
@426F6F Год назад
I wanted to print my tone in the Serial monitor but it only seems to be able to reach its highest when I use a high Baud rate and I have no idea why. Also, if I don't use the Serial monitor it sounds perfect. I guess the action of printing the value in the while loop introduced a tiny delay which distorts or lowers the frequency.
@samueltheprogrammer6145
@samueltheprogrammer6145 Год назад
yes, that is right, when you put "Serial.println()" in your code it slows down the speed of your Arduino a lot. Samuel
@louandpaulanickles7172
@louandpaulanickles7172 4 года назад
I did my math a little differently in the homework, but got the same results. I did part of the calculation outside of the program then entered the quotient directly in the program. I used buzzVal=((potVal*9.7165)+60);. Tell me, what is the purpose of the decimal point after your whole numbers in the calculation?
@EdwardRLyons
@EdwardRLyons 3 года назад
Question: Shouldn't the toneVal variable be a float, not an int? Otherwise there's no point in using the periods in (9940./1023.). And wouldn't it improve the sound from the buzzer, too? (I'm waiting for a passive buzzer to arrive, so I've not yet built the circuit and done the coding for myself.)
@prussianblue222
@prussianblue222 3 года назад
First, GREAT series. I am a hardware guy and learning to program is going well with your help. HOWEVER, it seems that timers in Arduino, maybe especially the older UNO (mine is 10 years old?) are really finicky. I was having lots of problems with this assignment and I had the serial monitor turned on so that I could see what was happening with all my values. Serial monitor seemed fine but the tones were jumping, not smooth. Was pulling my hair out until I turned off the serial monitor then Voila! It worked perfectly. Just something to watch for.
@GraveGear
@GraveGear 4 года назад
Completely forgot to plug everything into the equation after I found the slope. Was trying to convert with just "m"! Thanks for the video!
@dcar1234
@dcar1234 3 года назад
When you gave the home work originally did you say it backwards? You said all the way to the L you wanted 10K and all the way to the right you wanted 60? Would that not have been a negative slope?
@alicewang6342
@alicewang6342 3 года назад
Paul, I love you demonstrate the math for us! I am in my 40’s with very limited math and physics foundation, it is important for me to understand where the numbers come from before I start coding! Btw, can I ask a very stupid question: how do you know 1023 (5V) is equal to 10000hz rather than other numbers?
@eurekaibanez3697
@eurekaibanez3697 3 года назад
Thank you sir only all your works I did successfully to be operational.
@zudzifudushzy
@zudzifudushzy 2 года назад
That homework was super fun! I think you said 60 and 10000 in your assignment the other way around than in your solution, but that doesn't really matter :D I tried to work with as many variables as possible and added Serial.print with a high baudrate to have a look at the values. The high baudrate is to not mess up the timing of the tones. Here is my version of the homework: int buzzPin = 8; int buzzTime; float rightFreq = 60; float leftFreq = 10000; int potPin = A1; int potVal; void setup() { // put your setup code here, to run once: pinMode(buzzPin, OUTPUT); pinMode(potPin, INPUT); Serial.begin(2000000); } void loop() { // put your main code here, to run repeatedly: potVal = analogRead(potPin); buzzTime = ((rightFreq - leftFreq) / 1023 * potVal + leftFreq); Serial.print(potVal); Serial.print(" "); Serial.println(buzzTime); digitalWrite(buzzPin, HIGH); delayMicroseconds(buzzTime); digitalWrite(buzzPin, LOW); delayMicroseconds(buzzTime); }
@Traxonen
@Traxonen 2 года назад
Really interesting video. I'm lerning fast and easyly! Thanks a lot!
@michaeldrake2512
@michaeldrake2512 2 года назад
These buzzer ones I definitely hooked a switch up to reduce how much buzzing I actually had to endure haha. Hot tip for anyone else.
@denisebeck1050
@denisebeck1050 3 года назад
Thanks for this lesson, Paul. One question though, can you use map() instead of hard coding the function? It seems to return slightly different values.
@bandaralmutairi892
@bandaralmutairi892 3 года назад
Great video Paul. Isn't the 'tone' function meant to work perfectly with buzzers instead of the delays and highs/lows?
@erygion
@erygion 4 года назад
Great video Mr. Mcwhorter. My wife ran away! She doesn't like piezo speakers at all, thank you.
@MrJohnjamesboyd
@MrJohnjamesboyd 4 года назад
So did my wife, but with my industrial deafness I didn’t realise it was working lol
@billcrow5403
@billcrow5403 4 года назад
Great video. I change the toneVal around and played with those
@fetchfooldin3252
@fetchfooldin3252 3 года назад
I've just learnt how to fuse between math and programs. I diiid the assignment before completing the video. But forgot +60 in the equation (-_-;) Thank you so muuuuch
@basiceducation1131
@basiceducation1131 Год назад
Need your help.I have made an electric car.want to give it fake engine sound with Arduino..and programming
@sugumarprabhakaran3378
@sugumarprabhakaran3378 3 года назад
Hi Paul! I'm loving your series - thank you so much!. I bought myself an ELEGOO kit and have been following along. Just one thought: i think it would be great if you could make a video on the physics behind how the passive buzzer works. Thanks again,
@johnk2743
@johnk2743 4 года назад
Today my "The Most Complete Starter Kit" arrived so finally I could use the buzzer! Up until now was able to use components that I already had. Great kit, should have bought this together with my first Arduino! Lot's of thing I collected earlier but this kit is something else! The icecoffee is not for me, I stick to the hot variant. No sugar, no cream and strong! My viewing binge from the first video up to this one was fun and very informative! The (hot) coffee, my impatience and holding my breath (and some shouting at the screen as well, I confess) made it an intesive journey. In these pandemic times it's fun to play around with this Arduino stuff (while learning as well) and the partial lockdown we're under (I'm from the Netherlands) makes it a great way to spend the time at home. Your coding standards I recognize from my early coding days with Clipper. Thanks a lot for your teaching, it's fun, informative and very well produced! I wonder what tools you use making your video's. Thank you so much Paul!
@iplayflute
@iplayflute 3 года назад
Tip on how to boost the volume of your buzzer: tear out a piece of paper and place it above the buzzer, the larger diaphragm results in more vibration.
@batticha462
@batticha462 4 года назад
The hearing of high frequency tones depend on age, the younger the higher frequency to hear
@vitustillebeck4965
@vitustillebeck4965 3 года назад
yeah. thats why i heard all of em at 13. but thats just because im young.
@tedparker640
@tedparker640 3 года назад
I'm sorry, I can't hear you. can you please type louder?
@EFoxVN
@EFoxVN 3 года назад
Just a quick question/suggestion: Should toneVal not perhaps have been a float rather than an integer to get a smoother transition? Blessings
@paulrockwell9914
@paulrockwell9914 3 года назад
toneVal has to ultimately be an integer because the delayMicroseconds function is expecting an integer value for the delay. But we perform the calculations of the toneVal in float to get a more precise representation of where the toneVal point should be for a given potVal value.
@youssefshepl6892
@youssefshepl6892 4 месяца назад
I would like to confirm that in a linear equation, the independent variable, which in this case is time (timeT), should be placed on the x-axis, while the dependent variable should be placed on the y-axis. If there are any corrections or additional insights regarding this understanding, I would greatly appreciate your guidance.
@paulmcwhorter
@paulmcwhorter 4 месяца назад
That is correct.
@MrHayko666
@MrHayko666 3 года назад
Paul, when using passive buzzer and buzzing with variable voltage instead of microsecond delays, isn't it the same? Since the voltage variation is the delays itself of 5V and 0V?
@danielsaenz5570
@danielsaenz5570 Год назад
Great lesson! I think I prefer using the tone() function though, I was able to make so much different music notes with it! It was awesome!
@pradeepdube1398
@pradeepdube1398 Год назад
Hi Paul, Looks like I got confused with the terminology of ALL THE WAY LEFT and ALL THE WAY RIGHT you used. I understood it like this 1. delay = 10000 microseconds (when voltage V =0) 2. delay = 60 microseconds (when voltage V = 1023) Good thing is this created a line with slope towards right which was little difficult to create the equation. had to recall my mechanical engineering lectures from university as well as go through your previous Math notes I took. I was able to get the equation finally. delay = (-9940./1023.)*(voltage-1023.)+60; I printed over serial monitor to check my math part and formula calculation Arduino is doing in the background. Got perfect 10000 delay at 0V and 60 delay at 5V (1023 in Arduino). Rotating the potentiometer sounded like a world war siren... LOL..
@jnorris8649
@jnorris8649 Год назад
I would’ve used the map() function for the tone & potentiometer value. Good algebra refresher, though.
@shvideo1
@shvideo1 4 года назад
A. Very cool and fun project. Thank you for the math as well.
@ErlankBru
@ErlankBru 6 месяцев назад
This was a very cool assignment!🤠
@ashrafhabrumman1143
@ashrafhabrumman1143 4 года назад
Hi Mr.Pual Is it a good idea to put the output of potentiometer directly to input of buzzer (this is like analog)(and delay will be constant value)?
@alitanimola6422
@alitanimola6422 2 года назад
Paul, this is really great well structured and highly efficient. Thanks for bringing this to us Pls if I may ask what software do you use to create this kind of videos
@paulmcwhorter
@paulmcwhorter 2 года назад
Wirecast. OBS is a good free substiture
@ntg2006gr
@ntg2006gr 4 года назад
You are solving a different problem. You asked the tone to be 10000μs when potentiometer is all the way to the left and 60μs when potentiometer is all the way to the right. I don't think you mean with reverse polarity. Am I right?
@nobleforks8911
@nobleforks8911 Год назад
did the same thing with a LDR as well to show my 5YO(whom is very interested in the projects that I do), so he could play with it without ruining my pot(wouldn't be the first one he wrecked).
@danbishop4035
@danbishop4035 4 года назад
I appreciate learning and practicing the math...I had a careless moment and i used a period in void setup "pinMode(potPin.INPUT);" instead of "pinMode(potPin,INPUT);" which generated an exit status 1 Error compiling for board Arduino Uno. Nothing a few moments of debugging couldn't cure.
@ronaldjensen2948
@ronaldjensen2948 3 года назад
The frequency you get out of his code is 1/(2*buzzTime2 * 1e-6). For example, if buzzTime2 is 80, the frequency is 6250 Hz.
@georhodiumgeo9827
@georhodiumgeo9827 4 года назад
Thanks for the awesome videos. I don't see a resistor, I can't find a good datasheet on the ones i ordered from amazon but why do these not overload the MCU? Is the resistance just high enough you can't? Or do you really need to be switching them to prevent current from creeping up? Am I understanding correctly that the ATMega328 is powering it directly? Anyway thanks, your videos are very informative, love learning something new!
@philnewman1110
@philnewman1110 Год назад
Great video as always Paul, thanks!
@aaronmilliman7685
@aaronmilliman7685 2 года назад
Great lesson, I'm off to work and will knock out another one later.
@paulmcwhorter
@paulmcwhorter 2 года назад
Have fun!
@gavinpeddie6706
@gavinpeddie6706 2 года назад
Hey Paul! I think your buzzer sounded weird at the end because you declared toneVal as an int. If you declared it as a float, I think it would sound better!
@akhilmehta8248
@akhilmehta8248 4 года назад
Hi Paul, As you said, when you are to the extreme right, you want 60 micro-seconds delay and when to the extreme left, you want 10,000 micro-seconds delay. So, shouldn't the points be (0,10000) and (1023, 60)? Kindly let me know If I am wrong somewhere. Thanks
@fransvanenschot3286
@fransvanenschot3286 2 года назад
Hoi Paul, i like the way you explain everything from this tutorial step by step, so it is to following for everyone. aim already an experienced user, but i still like the way you explaining everything way. For a basic course it is the perfect way to learning, but maybe it is also a good idea to make also an tutorial with the arduino together with ethernet and HTML language, and build it up step by step. Another good idea is an step by step tutorial Arduino together with a big oled display what can used as HMI . I think this are tutorials were advanced users are waiting for, especially when you teach it in the same way as this tutorial, a few lessons for connecting the ethernet board , html for LEDS, html, for sliders, html for displaying, html for graphics, etc. thanks in advance, and go further with the good work.
Далее
Arduino Tutorial 26: More Fun with Photo Resistors
31:38
Million jamoasi - Amerikaga sayohat
12:37
Просмотров 497 тыс.
СТАЛ КВАДРОБЕРОМ
00:34
Просмотров 112 тыс.
Hacking a weird TV censoring device
20:59
Просмотров 3,1 млн
Using an EEPROM to replace combinational logic
25:22
Просмотров 1,4 млн
Why build an entire computer on breadboards?
28:43
Просмотров 3,1 млн