Click here to Skip to main content
15,902,932 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to build a Christmas light display for my family. I have it working for exception of the code. I am trying to write code for the Arduino to read the audio wav files from the (Audio Shield) and have an out put on pins 3,5,6,7 to control the relays which turn on and off the lights. I just cant my code to work. It will compile with no errors. But the Arduino will do nothing. No light display. Please help... Semper-Fi.....


Here is the video of my display.
http://youtu.be/TRksFeuEiPw?list=UUY9SBYJUlgkVGH-V9XREXOg


This is the code I have now, It will compile with no errors. But It does not work.

/*
This code is show how Arduino Wave Module works with Arduino.
Code is not optimized. Any improving work on it is encouraged.
Modified by USMC Junglist - Semper-Fi
*/

int CLK = 8;
int DAT = 9;


void setup() {
pinMode(CLK, OUTPUT);
pinMode(DAT, OUTPUT);


pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);


}

void loop() {
send(0x0000);//play file 0000
Serial.println("Play 1");
delay(10000);//delay 1 seconds


send(0x0001);//play file 0001
Serial.println("Play 2");
delay(10000);//delay 1 seconds

send(0x0002);//play file 0002
Serial.println("Play 3");
delay(1000);//delay 1 seconds

send(0x0003);//play file 0003
Serial.println("Play 4");
delay(1000);//delay 1 seconds
send(0x0004);//play file 0004
Serial.println("Play 5");
delay(1000);//delay 1 seconds
send(0x0005);//play file 0005
Serial.println("Play 6");
delay(1000);//delay 1 seconds
send(0x0006);//play file 0006
Serial.println("Play 7");
delay(1000);//delay 1 seconds
send(0x0007);//play file 0007
Serial.println("Play 8");
delay(1000);//delay 1 seconds
send(0x0008);//play file 0008
Serial.println("Play 9");
delay(100);//delay 1 seconds
send(0x0009);//play file 0009
Serial.println("Play 10");
delay(1000);//delay 1 seconds
send(0x0010);//play file 0010
Serial.println("Play 11");
delay(1000);//delay 1 seconds
send(0x0011);//play file 0011
Serial.println("Play 12");
delay(10000);//delay 1 seconds
send(0x0012);//play file 0012
Serial.println("Play 13");
delay(1000);//delay 1 seconds
send(0x0013);//play file 0013
Serial.println("Play 14");
delay(1000);//delay 1 seconds
send(0x0014);//play file 0014
Serial.println("Play 15");
delay(1000);//delay 1 seconds
send(0x0015);//play file 0015
Serial.println("Play 16");
delay(1000);//delay 1 seconds
send(0x0016);//play file 0016
Serial.println("Play 17");
delay(1000);//delay 1 seconds
send(0x0017);//play file 0017
Serial.println("Play 18");
delay(1000);//delay 1 seconds
send(0x0018);//play file 0018
Serial.println("Play 19");
delay(1000);//delay 1 seconds
send(0x0019);//play file 0019
Serial.println("Play 20");
delay(1000);//delay 1 seconds
send(0x0020);//play file 0020



send(0xfff0);//set voice volumn to 0 (turn off)
delay(3000);

send(0xfff4);//set voice volumn to 4
delay(3000);

send(0xfff7);//set voice volumn to 7
delay(3000);

send(0xfffe);// pause
delay(5000);
send(0xfffe);//play
delay(5000);

/*
//the following code is to play previous track
digitalWrite(3, LOW);
delay(100);
digitalWrite(3, HIGH);


//the following code is another way to pause and play
digitalWrite(5, LOW);
delay(100);
digitalWrite(5, HIGH);

//the following code is to play next track
digitalWrite(6, LOW);
delay(100);
digitalWrite(6, HIGH);

/the following code is to play next track
digitalWrite(7, LOW);
delay(100);
digitalWrite(7, HIGH);

*/
while(1);
}

/****************************************************
The following function is used to send command to wave shield.
You don't have to change it.

Send the file name to play the audio.
If you need to play file 0005.AD4, write code: send(0x0005).

*****************************************************/
void send(int data)
{
digitalWrite(CLK, LOW);
delay(2);
for (int i=15; i>=0; i--)
{
delayMicroseconds(50);
if((data>>i)&0x0001 >0)
{
digitalWrite(DAT, HIGH);
//Serial.print(1);
}
else
{
digitalWrite(DAT, LOW);
// Serial.print(0);
}
delayMicroseconds(50);
digitalWrite(CLK, HIGH);
delayMicroseconds(50);

if(i>0)
digitalWrite(DAT, LOW);
else
digitalWrite(DAT, HIGH);
delayMicroseconds(50);

if(i>0)
digitalWrite(CLK, LOW);
else
digitalWrite(CLK, HIGH);
}

delay(20);
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900