How to Play Audio on Arduino + Debug

  Рет қаралды 11,198

Make it happen!

Make it happen!

Күн бұрын

Пікірлер: 73
@InterlacedTech
@InterlacedTech 2 жыл бұрын
I feel terrible how this channel is underrated, your stuff is actually interesting and must be seen by the world... Try to use ranked tags for better search results.
@bob-ny6kn
@bob-ny6kn 2 жыл бұрын
Then check out Anas Kuzechie on the coding side.
@SeanPatrickGo
@SeanPatrickGo 6 ай бұрын
This video was so helpful! I've been trying to learn how to play audio with ardunio by watching many videos, but none were as successful as this one! Thanks! By the way, do you have any tips on increasing audio volume? (mine is fine, but not ideal for my requirements lol). I have a sound amplifier module but I am not sure if this is the best option.
@irfanrajput8236
@irfanrajput8236 2 жыл бұрын
I have followed the tutorial step-by-step, multiple times, card initialization is O.K, but the .wav file could not be played. Any further suggestions, please.
@MakeithappenDIY
@MakeithappenDIY 2 жыл бұрын
Did you do LED test? Is anything coming out of the speaker, i.e. buzzing or hissing? What speaker have you got, i.e. how many Watts and ohms? What transistor? Did you try and change volume()? Are you using separate supply or arduino supply? If separate, arduino and speaker need to share ground. It is hard to say without seeing your circuit. Have checked the wiring like 50 times?
@juanpedropena7464
@juanpedropena7464 5 ай бұрын
@@MakeithappenDIY hey, first of all great vid, i understood some things i had not before. Secondly i have a question, similar to this guy i cant get the audio to sound quite right, i tried sample audios already set to the right config, but i always get a static like sound. Im using an 8ohm 1W speaker and proved it worked without an sd by using pcm libraries with encoded audio. Any idea on anything i could do?
@MakeithappenDIY
@MakeithappenDIY 5 ай бұрын
@@juanpedropena7464 hi! Unfortunately, I gave all my suggestion answering the other guy... "static like" sound seems like the .wav file problem. If you have not tried this, I have a link to a github page in the video description. There is "like.wav" there which you could use to test your set up. That is what I used in the video. If you still get the problem, try changing the volume() function. Check the wiring again, go through the debug steps again. If you still can pin point if this is a hardware or software issue, try sending a single sine wave into the speaker from the code (google how to create sinewaves (might need to change to an analog pin!)). Don't give up, it will be something silly, you'll figure it out!
@Anonymous-hd7en
@Anonymous-hd7en Жыл бұрын
You summed up all things i need to know in one video , thank you very much .
@Anonymous-hd7en
@Anonymous-hd7en Жыл бұрын
I have one question : if i want to make it stereo not mono should i make audio parameters “ stereo “ and add another speaker with the same setup?
@MakeithappenDIY
@MakeithappenDIY Жыл бұрын
@@Anonymous-hd7en unfortunately it is not that easy. The software library cannot handle stereo, so if you encode is as "stereo" it will either not play anything or play some noise. And even if it did, the quality of this method is so poor that you could not tell the difference. The target aplication is simple buzzers or a couple word phrases. If you want to have good quality stereo, google "arduino audio stereo" and see what comes up. There are bound to be at least a few different methods!
@matteodoveri5170
@matteodoveri5170 Жыл бұрын
Hi ! I'm struggling reproducing my file audio , I think because of the way you convert itself. I'm italian and the website you used is down so I'm very disappointed and I cannot find an audio converter that make me able to change bit resolution channel ecc. I think the problem is here but I don't know how to fix it. I wish you can help me and my project. Thanks
@MakeithappenDIY
@MakeithappenDIY Жыл бұрын
Hi! I have a link to my github page for this project in the description. It has a like.wav file under audio_samples. This is a converted .wav file I used for the video. Try using that. You will be able to confirm if the problem is with the conversion. Hope this helps! Good luck :)
@Arbiter1223
@Arbiter1223 5 ай бұрын
​@@MakeithappenDIYI had the same problem where the sound I had converted played, but only garbage was coming out. I tried using the like.wav file included in the project, and it worked, telling me I hadn't correctly converted the audio files (I tried doing it in Audacity at first). Once I used the online converter, the sounds played nicely, although I am hoping to find a way to amplify the sound without causing it to distort. (I am building a portal gun from the Portal series and am aiming to have an activation sound and portal fizzle sound tied to a switch along with portal firing sounds that also trigger LED lights when one of two buttons are pressed.)
@MakeithappenDIY
@MakeithappenDIY 5 ай бұрын
@@Arbiter1223 first of all, cool project idea! I have just saw a video a few days ago of a guy who 3D printed GLaDOS, put in on a robotic arm, and made it a voice activated AI assistant handing from his ceiling (Portal series is awesome!). ...Anyway, in terms of electronics, the speaker is limited by it's own power rating (single digit Watts for small speakers like I used) and the supply source. If the supply is AA battery for example, I would guess it could not drive the speaker as well as say a Lithium batter (which as a smaller source resistance, thus better current driving capability). Powerful speakers plug in to the wall to produce 40W-60W-100W and more of power to blast the room. You will not get from the small speaker with this type of circuit, that is for sure. Having said that, there is a reason why speakers have large boxes -- they resonate to amplify the sound. So my advice to you is to come up with a way to create resonance in your portal gun. Make a little cone (as if a megaphone) to direct sound, or a chamber to resonate. The dimensions and material will matter, are pores on a surface (e.g. in 3d prints) or are the surfaces smooth -- all of that will matter but I am no expert in accoustics, so you will have to do your own research and trials. In any case, good luck!
@HerrHafiz
@HerrHafiz Жыл бұрын
do you need the 10 micro farad capacitor if you just using power source from the 9V plug or USB cable? because in my project i dont need extra power source
@MakeithappenDIY
@MakeithappenDIY Жыл бұрын
@HerrHafiz the cap is not essential. I talk about why it is useful in the video but you can live without it
@TravelersRuneAlt
@TravelersRuneAlt 2 жыл бұрын
hey, i finaly got everything working! it is just very very quiet, any help?
@MakeithappenDIY
@MakeithappenDIY 2 жыл бұрын
Great! What was the problem? Unfortunately, small speakers are quiet. You would need a more powerful speaker and run off higher voltage source. Or as I showed in the video have something that directs sound (plastic bottle in my case)
@TravelersRuneAlt
@TravelersRuneAlt 2 жыл бұрын
@@MakeithappenDIY I honestly don’t know the problem, I just debugged until it worked
@deathknight99938
@deathknight99938 Жыл бұрын
Hello! I ve been trying to do this and im kinda stuck. What should i do if by doing the led test on pin 9, the led blinks only once? Also, instead of using a speaker , im trying to use in my project a 3.5 mm jack instead. Any idea how i might be able to do that? I found a trrs jack module that might help Edit: succeded in making the led blink however i still dont get any sound. Perhaps its from the speaker? I have an 8 ohm 1 W
@MakeithappenDIY
@MakeithappenDIY Жыл бұрын
@deathknight99938 Hey, I am glad you can see data coming out of your Arduino now! It is hard for me to advise anything other to what the video already suggests. Make sure that your amplifier is wired correctly; the speaker you are using should be OK. As for the 3.5mm jack, it is essentially just a wire so it will work. Again, just make sure you wire everything correctly: connect the L and R channels to the amplifier supply and connect the ground of the 3.5mm jack to the collector of your NPN and this should be OK. Good luck!
@serentynym3569
@serentynym3569 Жыл бұрын
when i put my oscilloscope on the pin 9 output, im not getting PWM, it just has supper small spikes in the wave up to 5v but only for a fraction of a microsecond. ive tried everything but i cant seem to get it to work
@MakeithappenDIY
@MakeithappenDIY Жыл бұрын
@serentynym3569 what arduino are you using? Google its pinout and make sure that pin 9 is PWM compatible. Next, write a simple code which continuously produce PWM signal to make sure the problem is not with the switch. The signal will be full scale (5 or 3.3V). Make sure you have ground of the oscilloscope connected, that you use the right channel, etc.
@serentynym3569
@serentynym3569 Жыл бұрын
@@MakeithappenDIY i have a Nano, and i just checked and got a PWM signal and it works on Pin 9, working through both the oscilloscope and the speaker
@MakeithappenDIY
@MakeithappenDIY Жыл бұрын
@@serentynym3569 glad to hear that! 👍
@serentynym3569
@serentynym3569 Жыл бұрын
@@MakeithappenDIY it worked with a sample of PWM not the proper circuit (testing the pwm to make sure that wasnt at fault)
@MakeithappenDIY
@MakeithappenDIY Жыл бұрын
@@serentynym3569 ok, I see. So might be that your button is wired wrong.
@DavidZech
@DavidZech 2 жыл бұрын
Amazingly well done video!
@farhad6365
@farhad6365 11 ай бұрын
please make a video where i2c eeprom is used to store the audio....
@m3lateef
@m3lateef Жыл бұрын
should we use electrolytic capacitor or ceramic capacitor ?
@MakeithappenDIY
@MakeithappenDIY Жыл бұрын
It is hard to find electrolytic capacitors past 1uF so for power supply decoupling you normally see electrolytic capacitors. Having said that, it does not matter. For low frequency filtering both will perform the same. The diferences between different types show up in high frequency filtering were equivalent series resistance and inductance start to matter. Actually you might see sometimes in high quality audio circuits that power supply is filtered using 10uF electrolytic cap together with a much smaller ceramic cap in parallel. This is because electrolytic caps though great for low frequency filtering do poorer job filtering high frequency
@m3lateef
@m3lateef Жыл бұрын
@@MakeithappenDIY Ok thanks. I will use two 10uF electrolytic caps for miicrocontroller's power pairs
@khaliq-fg1bb
@khaliq-fg1bb Жыл бұрын
Can i use BC547B Transistor instead of NPN?
@MakeithappenDIY
@MakeithappenDIY Жыл бұрын
You should be able to use BC547B. Just make sure you get the pin names right. Note, NPN refers to the way the transistor is made (NPN or PNP) whereas BC547B is a name given by a manufacturer. I.e. there are multiple names for the different flavours of NPN and PNP transistors. BC547B happens to be NPN type so it will work.
@khaliq-fg1bb
@khaliq-fg1bb Жыл бұрын
@@MakeithappenDIY Hey thank you so much it's working for me !
@mwhite9707
@mwhite9707 2 жыл бұрын
Hi Make it happen Is it possible to expand this prototype to 6 buttons with the necessary hardware e.g. 6 resistors, 6 compactors etc... If so would I need extra power to the Arduino
@MakeithappenDIY
@MakeithappenDIY 2 жыл бұрын
It depends what you want to do... if you want to have 6 speakers and play six different things at the same time, then no. It would be like asking one head to think about six different things at the same time. If, however, you want to have six buttons to control what is playing, have a volume control, etc., then yes, absolutely. No extra power needed. But the handling of the button presses would be different. There are only a couple of interrupt pins on arduinos. They help to "interrupt" arduino and tell it that something happened (i.e. button pressed). The alternative is to check normal digital pins in the main loop of the code very often. You could register 6 button presses no problem. Hope this helps.
@mwhite9707
@mwhite9707 2 жыл бұрын
@@MakeithappenDIY It makes it somewhat clear. I am trying to have six buttons that when pressed they play there each individual sounds. These sounds are all on a SD card. I have tested if the Arduino can read and write in the SD card which it can so the Arduino can access the the SD card fine. The problem I'm having is trying to code the Arduino to scan the SD card for the right file and play the sound. For example button 1 is pressed which should play a dog barking.
@MakeithappenDIY
@MakeithappenDIY 2 жыл бұрын
So if I understand correctly, one speaker and 6 buttons. This certainly is possible. What is more, I think you can have those sounds overlapping if you wanted, i.e. if you click a different button before the dog barking stops, you could have the new sound on top of the barking if you wanted. As for the implementation, it seems it should be as easy as having an if else statement in your loop(). E.g. if (button1) {sound.play("dog.wav")}; else if (button2) {sound.play("cat.wav")}; etc. (where button1 and 2 are digital pin numbers and have their modes set to input (i.e. pinMode(button1, INPUT)). If, however, the problem you're having is not related to registering buttons but rather actually playing files, it could be that they are not converted to the right format. You can test this using "audio sample" from my github repository.
@mwhite9707
@mwhite9707 2 жыл бұрын
@@MakeithappenDIY Yh that is exactly what my project is thank you very much for the help I do believe this does help me a lot
@jyfyjf
@jyfyjf 9 ай бұрын
how can I boost the sound, I used 4 ohms, 3 watts
@MakeithappenDIY
@MakeithappenDIY 9 ай бұрын
@jmsalvania4355 as I say, the speaker will not give more sound with this setup but some accoustic element will. Make a speaker box or some cone shaped thing to use as a type of megaphone
@NeoWorldScience
@NeoWorldScience 6 ай бұрын
Great demonstration ✌
@yenterary3228
@yenterary3228 Жыл бұрын
Hello, does anyone know if an 1W 8ohm speaker will work with this? Some people said this will fry my arduino
@MakeithappenDIY
@MakeithappenDIY Жыл бұрын
@yenterary3228 an argument can be made that if you put the speaker between an arduino pin and ground (it is the same as shorting arduino to ground through an 8ohm resistor), you will damage the arduino. 5V/8ohm is 625mA which is higher than max rated current of 40mA. But I hope noone is connecting the speaker like this! The video instructs using a transistor amplifier. The NPN resistor has a current gain of anything above 50 which means that the current into the transistor will be in the worst case 625mA/50 = 13mA. Also the current is pulsed so arduino can handle more than 40mA. So, I think you are safe :)
@yenterary3228
@yenterary3228 Жыл бұрын
@@MakeithappenDIYIm halfway through your tutorial and im using an npn 2n2222A and that apparently has a current gain of 75v, even better
@MakeithappenDIY
@MakeithappenDIY Жыл бұрын
@yenterary3228 this number (75) is highly unreliable. You can buy 10 identical transistors and they all have a differen current gain. What is more, this number changes like crazy with temperature. just by touching the transistor with a finger you raise the temperature enough for the gain to change by ~10. In good circuits the current is set by resistors and kept constant with negative feedback so the current gain does not matter at all. But here I just show a simple circuit that anyone can build :)
@yenterary3228
@yenterary3228 Жыл бұрын
@@MakeithappenDIY I see, thank you for your time! :D
@Funstrix-xl3it
@Funstrix-xl3it 10 ай бұрын
Thanks For Making This video
@devdarshchandk5922
@devdarshchandk5922 Жыл бұрын
superb well done
@TravelersRuneAlt
@TravelersRuneAlt 2 жыл бұрын
I keep getting port busy
@TravelersRuneAlt
@TravelersRuneAlt 2 жыл бұрын
Now it’s error opening sketch
@MakeithappenDIY
@MakeithappenDIY 2 жыл бұрын
Sounds like you are missing something. Can you open other sketches?
@TravelersRuneAlt
@TravelersRuneAlt 2 жыл бұрын
@@MakeithappenDIY yes
@TravelersRuneAlt
@TravelersRuneAlt 2 жыл бұрын
@@MakeithappenDIY I eventually gave up, now I’m trying again from scratch, I’ll tell you if I get it again
@TravelersRuneAlt
@TravelersRuneAlt 2 жыл бұрын
I’ve checked my wiring and I’m now getting initialization failed
Building a Digital Music Player with I2S?! What is I2S! EB#45
10:24
Motion-activated Sound Effects with Arduino, PIR Sensor & MP3 Player
25:26
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 44 МЛН
Wall Rebound Challenge 🙈😱
00:34
Celine Dept
Рет қаралды 22 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 29 МЛН
Audio modules for electronics project
37:54
Playful Technology
Рет қаралды 67 М.
Play MP3 Files on ESP32 Without Codec Chip: Easy Guide
8:51
atomic14
Рет қаралды 93 М.
Teensy Audio Tutorial & Workshop
48:38
PaulStoffregen
Рет қаралды 140 М.
Why build an entire computer on breadboards?
28:43
Ben Eater
Рет қаралды 3,1 МЛН
Play WAV files on Arduino
13:47
H3 Technology
Рет қаралды 11 М.
Easy Diorama and Book Nook Audio - DFPlayer Mini #dfplayer-mini
10:11
Random Making Encounters
Рет қаралды 28 М.
Port Register Control | Increase speed of Read/Write - Arduino101
15:22
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 44 МЛН