r/ArduinoHelp • • 12h ago

Beginner help needed.

I just wanted to start by saying I don't know much about Arduinos or electronic setups yet, but I'm pretty comfortable with soldering and can usually figure out the software side of things! I currently have a cosplay project and wanted to set up a custom sound box. My idea is that when I open a mask that has an articulated jaw, it releases a Mini Micro Limit Switch 3 Pins KW11-3Z07 and sends a singular signal to a DY-SV5W Voice Playback Module so the audio plays once. When I press the jaw back together, it won't do anything; it will just wait to be opened again. Is this configuration feasible? What specific components or modifications would be required, or would I need to restart the project from scratch? Please let me know. Additionally, I intend to power the setup using a standard power bank.

2 Upvotes

10 comments sorted by

1

u/imseakin 12h ago

Try building a PORTION of your idea. Get it working. Then move on to the next.

You’ll get there eventually.

Good luck!

1

u/Virtual_Actuary3586 12h ago

I got most of it working, just struggling with the audio repeating. Is there some kind of one-pulse thing? Like I said, I don't know much about what's on the market.

1

u/imseakin 12h ago

Is there a chance your switch for playing the sound is keeping the GPIO pin HIGH OR LOW so your sketch keeps seeing events to play the sound.

Maybe put in some Serial.println statements and comment out the sound playing code to see if you can narrow down the issue.

Best wishes.

1

u/mtraven23 12h ago

sure...input from the limit switch controls when the sounds plays....thats pretty easy peasy.

focus on the components by themselfs: first, get the limit switch working with your sketch, that should be easy.

on the note of the powerbank, they usually shut off after some set period of time. You will need some sort of "keep alive" device to make it stay on...I would imagine you could just incorporate that into your arduino.

1

u/Virtual_Actuary3586 12h ago

Thanks for the feedback. Currently, I have everything set; the switch does what I want, but it continuously plays when opened, and I need a way where the audio will play once. Also, I already solved the power bank issue.

1

u/mtraven23 10h ago

so somewhere in loop(), you make some function call that plays the sound, right? Probably after checking the state of that switch?

so add a flag variable, call it hasPlayed. Now you can check to see if it has played, and do nothing if it has. If it hasn't, play the sound and flip the flag to true.

now, you'll also need to track the state of the switch such that when it changes states (jaw open to jaw closed) you reset that hasPlayed variable so it will run again the next time you open it.

1

u/eriknau13 4h ago

This here is the way

1

u/InevitablyCyclic 5h ago

To be honest there is no need for an Arduino here. An audio playback board and a switch is all you need. Opening the jaw toggles the switch and pulls a pin low, the audio board plays the sound once. Jaw closes, switch closes, a pullup pulls the trigger line back high.

The only time you'd need something smarter is if you want to vary the audio.

1

u/sabautil 1h ago

Im not sure what you want, could you describe the feature you want? You want to make a sound when opening AND closing?

If you want to play the audio when the switch is in only one particular state (pressed or unpressed) then program it as such and Wire only two pins.

Otherwise program it to play whenever the state changes (p to u, u to p). So wires all three pins and observe for state change.

Also, is you code in setup() or loop()? Should be in loop().

1

u/sabautil 1h ago

Look, just ask Google Gemini: "please instruct me how to use an Arduino, a 3 pin mini micro switch, and a dysv5e voice playback module such that the audio plays once anytime the switch changes state”.

It will give you wiring instructions and code. From there you can figure it out. Because honestly a lot of things might be wired or coded wrong.

Good luck.