this post was submitted on 30 Jan 2024
10 points (85.7% liked)

raspberrypi

3255 readers
4 users here now

Community about the single-board computers, micro-controllers and related projects.

https://www.raspberrypi.com/

Other RaspberryPi communities on Lemmy

founded 4 years ago
MODERATORS
 

Hello, I’m starting a project to build something for a friends kid who’s father is a Huey pilot. I ordered the switch/panel in the image and want to 3d print an enclosure to mount it on that plays the song when the switch is in the on position.

Per the website the switch is fully functional, I just need to wire it to something to use it. Does anyone have suggestions on a bare bones controller to use and how to set it up to play an MP3 so long as the switch is in the on position? In a perfect world I would love for it to resume the position if it’s quickly toggled but restart if it sits more than a minute or so but realistically just playing the song would be more than enough.

While I’m new to Raspberry Pi I’m not that daunted by the task. I’ve been soldering since elementary school and have a degree in comp sci, but haven’t done any coding since graduating 10+ years ago. I do have a Pi hole but using an off the shelf package on a premade pi with step by step instructions doesn’t really count as “experience” for pi in my opinion.

Any suggestions are welcome, especially if someone can recommend some mini speakers that actually sound half decent. I’m not looking to tear a Bose Bluetooth apart but something slightly less tin-canny than a 2004 Nokia ringtone would be nice.

Thanks in advance!

all 9 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 9 months ago

I would likely start here:

https://raspberrytips.com/raspberry-pi-gpio-pins/

You'll need some code running at startup as a daemon for monitoring the pins on the rpi, but once you have that, triggering literally whatever you want from the python script is one os.popen() away.

[–] [email protected] 2 points 9 months ago (1 children)

I think the easiest method is to go analogue. Get a tape player with the play button pressed in, and a tape with the song recorded back to back on both sides. Solder the switch to the power connector for the tape player. Done!

Otherwise you'll need a Pi, a speaker, an amp, some wiring, an enclosure, and a bit of coding.

[–] [email protected] 1 points 9 months ago

Yeah, I would rather do a Pi or Arduino and some coding. I was already planning on 3d printing an enclosure.

[–] [email protected] 2 points 9 months ago (1 children)

Hey there, happy to make some suggestion. Just need to know more about where this will be installed.

Power Will the switch be switching the power or will it be a play switch? What voltage is available in the space the switch will be installed in?

Space How much space will you have behind the switch when it is mounted OR do you intend to have the playback device somewhere else? Will a PC speaker fit or do you want something more serious?

Budget What's your budget?

Time How long have you got before this needs to be finished?

[–] [email protected] 1 points 9 months ago (1 children)

Space: I was going to 3d print a box for it. The switch is 3x3” so I was thinking of approximately a 3x3x3 cube but slightly angling the panel back a bit to truncate the front corner would look nice. I have leeway to adjust the enclosure as needed since I’m developing and printing it myself. A single 2-3” diameter speaker would fit and I can adjust the enclosure around it and convert the mp3 to mono as needed.

Power: Power is flexible to whatever solution seems best. I envisioned it as a desk ornament so first thought was a USB jack on the back. Not 100% tied to that but figured it seemed the easiest. My goal was to have the switch play the music so long as the device has power available.

Budget: I was envisioning $50 or so for components but can be flexible within reason. The controller needs to run a few dozen lines of code and have enough memory for a single mp3 so I can’t imagine it will be that expensive.

Time: Not stuck on any specific timeline. The friend is visiting with the kid in 2 weeks which would seem doable if I don’t get distracted. If not his birthday is in April and even then I can send it whenever it’s done or I see them next. She’s going through a divorce with the pilot father so a positive gift tied to the father would be really nice for him to have, there’s a whole backstory there that isn’t worth getting into. In short, 2.5 weeks would be great but “when it’s done” is acceptable.

[–] [email protected] 1 points 9 months ago (1 children)

Sorry, I accidentally deleted my thread. I found a dataaheet which suggests it would need a microcontroller passing data using SPI, this would end up requiring code. It just sounds like you need a stand alone mp3 decoder with a trigger, like ones in cards. The search continues....

[–] [email protected] 1 points 9 months ago

Yeah, I'm looking at some of the options. I like this speaker set so an option with an analogue jack and USB port for power seems the way to go. Whether I go for a Pi or just a simple Arduino board doesn't matter to me. I think I'm going to be messing with code anyway to get the switch behavior I want since most existing MP3 options seem to be standard play/next/prev controlled with multiple momentary buttons vs a toggle. Even just toggle on to start the song each time will need a bit of customizing and at that point I might as well make it a bit more fancy with off being pause and then a timer for back on to be unpause if it's a short period or play from the beginning if it's been sitting for a few minutes.

It's still a first dive into any of this for me, Pi or Arduino but with a bit of help pointing in the right direction none of it seems that hard. Just trying to figure out which hardware to go with and once I have it playing with it until I get what I want.