Puppet Arcade Game

Hey Guys,

I have an electro-mechanical arcade game that has some poorly rigged electronics in it. I'm going to replace that mess with an Arduino.

This is a marionette that dances and sings to music. Here's the sequence of operation, how it originally worked:

  1. Dime inserted into plunger-type slot. This throws a switch which turns on the motor, lights, and starts the music.

  2. The motor (which makes the marionette move side-to-side and makes his mouth cycle open and closed) and lights stay energized while the song is playing through a proprietary tape player.

  3. The circuitry listens for the 4 seconds of silence between each song on the tape. When the circuitry stops hearing music (indicating that the 4 seconds of silence between the songs has been reached), the lights and motor are de-energized

I am using an Arduino Uno R3 and a SEED Studio Relay Shield. I also have all 9 of the puppet's sings on a micro SSD card that resides on a Sparkfun MP# Trigger.

My question is, what is the best approach for creating an algorithm that will work for this hardware setup?

When the dime is inserted, the switch is triggered in momentary fashion. It cannot mechanically stay triggered. So I need the Arduino to energize the motor and lights relays upon a momentary-contact switch closure.

Then I need those relays to de-activate once the song has finished playing. So far I haven't found a signal I can grab from the MP3 Trigger board that indicates the song is over. Is there another way to perhaps have a pin on the arduino "listen" for silence.

I'm sure this description is woefully quirky and incomplete. Please bear with me as I'm a noob to the Arduino world.

tldr:

To nutshell it, I need to energize 2 relays on the relay shield when the momentary closure of a mechanical switch is detected. I need them to stay energized until an MP3 file plays through the speakers, at which point the relays will de-energize.

I have no need of help with the relay shield. Rather, i don't know how to energize based upon an external switch, nor how to de-energize based upon the absence of sound.

Thanks!

You control the relay. You are not directly using the switch or sound state to control the relay.

Step back and ask- "how can I change the value of a variable based upon an external switch" and "how can I change the value of a variable when there is no sound"
because that's all you need to figure out. The rest is just an intelligent use of those variables in code.

Your songs are on an MP3 player - you know how long they take. So you don't need a "song finished!" signal. Just wait for the song to complete, and stop the motors (switch off the relay).

So basically what you have to do:

  • wait for a coin to be entered in the slot.
  • (do you want to allow the user to add more coins while playing? What to do with this?)
  • select a song (randomly? button?), and tell the mp3 player to start playing that song.
  • activate the relay - motor starts running.
  • wait until the song is done (pure time based).
  • stop the motors.
  • wait for the next coin.

From the Sparkfun documentation:

The MP3 Trigger sends the following ASCII messages:

‘X’: When the currently playing track finishes.
‘x’: When the currently playing track is cancelled by a new command.
‘E’: When a requested track doesn’t exist (error).

Thanks guys. I can't use a timer for the end of the songs because each one is a different length. They probably vary within a range of 30 seconds or so. In fact the main reason I want to use a microcontroller is to get rid of the current relay that has a built-in timer that sometimes stops late and sometimes early, depending on the song, because the relay is time-based.

To wildbill, thanks for the info. I was hoping to avoid serial communications as I'm new to this and was hoping to stick to switches and digital inputs (in order to get it done as quickly and simply as possible). However, if necessary I will learn what I need to learn in order to implement via serial. I won't shy away from learning what I need to learn.

steambc:
Thanks guys. I can't use a timer for the end of the songs because each one is a different length.

You know which song you play, and you know how long each song takes. Say song 1 is 90 seconds, song 2 is 103 seconds, etc. Then you just base your timeout on that number.

Or indeed wait for the mp3 player to tell you it's done.

Or you can do like reply 3 and get the module 'X' response, or 'x' or 'E'.

GoForSmoke:
Or you can do like reply 3 and get the module 'X' response, or 'x' or 'E'.

^This...

trying to hardcode the length for audio is NOT the correct approach.. (thats a last ditch effort approach IMHO)..

I also suggest you DO learn the serial comm basics.. (they are used for a lot of communication between devices)..

There is a sticky post in most forums (by Robin2 I believe).. that covers everything you need with examples. Its easier than it looks at first.. grasp the basics...and you'll be fine!)

I also think checking out the blink without delay & state change examples sketch in the IDE will help you for detecting your momentary 'switch/coin slot' scenario..