Hello and thank you for taking the time to help. I build models for my son to hang in his room. I have gotten bored with model kits and I started adding lights in engines, added motors to run propellers and I am moving on to scratch builds. I am trying to make something new for my 7 year old son and I am running into some problems.
The set up:
Build a turbo laser tower that plays an audio file and blinks some LEDs. For those of us who are star wars nerds, we have all seen the Tony Agustin turbolaser tower.
starshipmodeler.com/starwars/ta_tower.htm
Well my son liked it so I started building my own. I want the tower to play a WAV file (about 15 seconds long) and the (2) LEDs in the gun barrels to flash when the lasers fire in the audio clip. This seemed simple enough when I was thinking about his toys that play a sound and light up different ways when you push a button. So I got a microcontroller and an audio recorder. arduino uno and VMA02 audio shield.
My problem:
I cannot get my light sequence to run when I play the audio clip.
What I have done:
I know the light sequence runs independent of playing the audio, tested and works. Although, the pin outputs don’t really put out the amps I was expecting. I read the output was 5 volts at 40 mA, but my leds are 4 volts at 30 mA and it barely lights up. I will wire an external battery with a relay off the pin out for this.
I know the code works for the audio shield as I have recorded and played multiple times.
I have tried writing the code to do the light sequence under the play switch case and I have tried writing it to play in the light sequence. I can’t initialize both and wondering if someone could tell me why.
Here is the code for the light:
const int buttonPin = 2;
const int ledPin = 13;
int buttonState = 0;
pinMode(ledPin, OUTPUT);
pinMode(buttonPin,INPUT);
buttonState = digitalRead(buttonPin);
if(buttonState==HIGH){
chip.play();
digitalWrite(ledPin, HIGH);
delay(4000);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(300);
etc…
The code for the audio player is:
void loop()
{
char c;
if(Serial.available())
{
/* Power Up */
chip.pu();
c = Serial.read();
switch©
{
case ‘A’:
break;
case ‘Y’:
chip.play();
case ‘y’:
chip.set_play(startAddr,endAddr);
Serial.println(“PLAYING2”);
break;
The printline “playing2” is an example of where I tried putting the light code. I started simplifying it to just print lines and watching on the serial monitor to see if I could figure out what was initializing the chip to play, but I couldn’t figure it out.
Please help…
Oh and once this is said and done, it will not have to record and play any other sounds.