EEVblog Electronics Community Forum
Electronics => Projects, Designs, and Technical Stuff => Topic started by: Youkai on May 02, 2020, 04:38:13 am
-
I'm working on a night light project which is based on the "Wishing Tree" from the Netflix show "True and the Rainbow Kingdom". I'd like to have a button on the light that when you press it will play one of a selection of audio clips.
In the past I was able to get something like this to work by having an Arduino send serial commands to a Raspberry Pi when buttons were pressed. Then I had a small battery operated speaker plugged into the 3.5mm audio port on the Pi. It worked but there has got to be a better way.
Notes on the build:
- The project is going to have some RGB LED that I need to control. Probably a few that need to be controlled separately but I can chain together NeoPixels and control them from a single pin if necessary.
- There will be at least one button I need to monitor, possibly a few.
- It doesn't need to be loud (like an alarm clock). I just want a person standing next to it to be able to clearly hear the sounds.
- I'll be planning on using a wall plug to power the thing.
- The tree sits on a "hill". I'll put the bulk of the electronics in the hill and I'll be able to make as big as I need; within reason. So I don't need to keep everything micro sized but I do want it to be reasonably small.
What is the best way to control all of this? Is a micro controller right? Or is something like a Raspberry Pi more what I need?
You can view my build journal for more info: https://docs.google.com/document/d/1d1cgzCqczD67msppKzNe46_WDqtxqITs4bIEhIbP3HY
-
Definitely a microcontroller, I see absolutely no reason to have a fullblown computer running an operating system to do something so simple. You can get little boards that play audio files off a SD card for just a few dollars. You can control them with an Arduino or any other microcontroller.
-
Ok. That's good to know. Do you have a search term I can use to google this?
-
While Arduinos based on AVR mircos don't have the umpf to play audio themselves, there are compatible mp3 boards that you can plug into them that can. Such as this one:
https://www.sparkfun.com/products/12660 (https://www.sparkfun.com/products/12660)
RPi is an overkill.
-
Search for arduino sound player, or mp3 player.
Some very cheap solutions like this that might work, I have not tried one of these specific boards.
https://www.ebay.com/itm/1pcs-WT588D-16p-voice-module-Sound-modue-audio-player-For-Arduino/201430043660? (https://www.ebay.com/itm/1pcs-WT588D-16p-voice-module-Sound-modue-audio-player-For-Arduino/201430043660?)
-
OTOH for a one-off, a Pi Zero may well be the best option (Not a Pi Zero W - you don't need the connectivity) By the time you've added a MP3 player board to a lesser MCU board you've got a larger and most likely more expensive assembly. The Pi Zero has enough I/Os to handle plenty of buttons and, if you aren't too fussy about audio quality, you could connect one of its PWM audio output channels direct to a H-bridge IC to drive a small speaker. If you want better quality, you'll need a low pass filter and an audio amp, possibly even duplicated for stereo using both PWM channels
It would be preferable to use APA102 LEDs with the Pi as their SPI-like interface doesn't demand the hard realtime pulse width control that is required while updating Neopixels, however it is possible to drive a single Neopixel string with a Pi if you use its UART to generate the pulse timings. See https://wp.josh.com/2014/09/03/inside-neouart-tricking-a-serial-port-into-being-a-signal-generator/
OTOH it would certainly be more elegant to put everything including the audio samples on a single MCU without resorting to external SD cards, MP3 players etc. and without the overhead of running a full OS. Perhaps the O.P. could reply with the total length of the samples and the minimum acceptable sample rate so we can see if its feasible to play everything from program memory on any readily hobbyist-accessible MCU?
-
Thanks for the posts guys. Seems like lots of good info here. Much of it uses acronyms for things I don't have experience with. So I'll need to do some research then I'll post my thoughts about how I could proceed.
Perhaps the O.P. could reply with the total length of the samples and the minimum acceptable sample rate so we can see if its feasible to play everything from program memory on any readily hobbyist-accessible MCU?
To respond to this. My thought was that I would take some small 1 - 5 second audio clips from the show. They will be mostly talking (i.e. not music) and I'm sure whatever speaker I hook up will be fairly cheap. That being the case a medium/low sample rate WAV or MP3 or whatever will work. As long as the quality is good enough that you can clearly understand what's being said. I'm thinking there will be a total of 30 seconds of audio or less.
-
Search MP3 player module on AliExpress, it should be around $1.
Something like this? https://www.aliexpress.com/item/33047673289.html?spm=a2g0o.productlist.0.0.126f1704XKgZEE&algo_pvid=61d5077c-a72e-4d5d-b449-225e623f9e72&algo_expid=61d5077c-a72e-4d5d-b449-225e623f9e72-3&btsid=0ab6f82215884482491768448e23af&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_ (https://www.aliexpress.com/item/33047673289.html?spm=a2g0o.productlist.0.0.126f1704XKgZEE&algo_pvid=61d5077c-a72e-4d5d-b449-225e623f9e72&algo_expid=61d5077c-a72e-4d5d-b449-225e623f9e72-3&btsid=0ab6f82215884482491768448e23af&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_)
So I would put the audio files on a memory card and then there would be a few pins to the arduino to tell which files to play and also a few pins to a speaker. Is that correct?
EDIT: Ok yeah seems right. Found a couple youtube videos about it. This seems like it's probably the cheapest/easiest way to go and it's reasonably small. A proMicro or similar and one of these chips will work fine.
-
I was wondering about amplification. One of the youtube videos I watched about using a DFPlayer module with arduino also used a PAM8403 amplifier. It seems I can get a 2 pack on amazon for about $8. Is that something I'm likely to need?
I'm thinking for simplicity sake I'll probably wire this project up on a solderless board for the final build; I haven't had much luck soldering strip board recently. So I should probably use a small Arduino compatible MCU and preferably one that comes with header pins pre-installed. I have a 5v pro micro already which could work but if there are other suggestions on what might be a good board please go ahead.
-
There's probably a library already out there to drive these things, most of the time that's the way it is with these Chinese widgets, you just wire them up and find a library to make them work.
You will probably need an amp, I've used those little PAMxxxx modules before and they work very well, I don't think I ever paid more than $1 for one.
A solderless breadboard is for temporary testing, it's not appropriate for a final build. What issue are you having soldering headers? Perhaps it would be good to spend some time practicing soldering, it's hard to get very far in electronics without being proficient at that. Soldering those huge 0.1" header pins should be trivial.
-
It wasn't soldering the headers. It was soldering my circuit together on my stripboard. I had three rows with 15 holes each as well as a couple breaks in the strips. Tried to do it using three adjacent strips. Failed twice. First time it didn't work at all. The second time it mostly worked but I had some short somewhere that was causing my pulldown to not work and it left my arduino input floating.
You are right I should try again. The space constraints won't be as tight on this project so I can probably afford to leave a an empty row on the stripboard. I'm sure it was some combination of me being new to soldering (not very skilled), and trying to wire a complex circuit (relative to my skill level).
-
You could also try wire wrapping, it works reasonably well with the square header pins. When I use perfboard I use the stuff that just has holes with pads, no strips connecting anything. I use kynar wire to make the connections.