Hello guys,
I have one big problem. I try to make some sort of light interactive music player using Arduino UNO, Music Maker MP3 shield from Adafruit and a LPD6803 rgb led strip.
Here you have some links for of the products:
Music Maker -> Adafruit Music Maker MP3 Shield for Arduino w/3W Stereo Amp [v1.0] : ID 1788 : $34.95 : Adafruit Industries, Unique & fun DIY electronics and kits
RGB LED STRIP ->
So, this setup is like that : when the light sensor senses that the light droped below a certain value, it should do some random effect on the rgb led strip and alos, to make a sound from an SD card. When i upload the program without the sound it works just fine but the problem is when i play the sound. It simply stops. The .mp3 file from the SD card it's a harp sound of 1 and a half second.
From what i found from other forums, it might be a problem with communication but, i don't know how to solve it.
Down below you have the code :
#include <FastSPI_LED.h>
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
#define NUM_LEDS 29
// Sometimes chipsets wire in a backwards sort of way
struct CRGB { unsigned char r; unsigned char g; unsigned char b; };
struct CRGB *leds;
#define dataPin 5
unsigned int Display[NUM_LEDS];
int random_effect = 0;
int contor_break = 0;
int idx_offset = 0;
#define PRAG 50
#define BREAKOUT_RESET 9
#define BREAKOUT_CS 10
#define BREAKOUT_DCS 8
#define SHIELD_RESET -1
#define SHIELD_CS 7
#define SHIELD_DCS 6
#define CARDCS 4
#define DREQ 3
Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
void setup(){
uint32_t seed = 0; // Generate random seed
for ( uint8_t i = 10 ; i ; i-- )
{
seed = ( seed << 5 ) + ( analogRead( 3 ) * 3 );
}
randomSeed( seed );
musicPlayer.begin();
SD.begin(CARDCS);
musicPlayer.setVolume(1,1);
Serial.begin(9600);
FastSPI_LED.setLeds(NUM_LEDS);
FastSPI_LED.setChipset(CFastSPI_LED::SPI_LPD6803);
FastSPI_LED.setPin(dataPin);
FastSPI_LED.init();
FastSPI_LED.start();
leds = (struct CRGB*)FastSPI_LED.getRGBData();
off();
musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);
}
void loop(){
int valoare_senzor = analogRead(0);
albastru();
int test = 4;
if(valoare_senzor < PRAG){
musicPlayer.playFullFile("track001.mp3");
random_effect = random(1,6);
}
Serial.println(valoare_senzor);
switch(random_effect){
case 0 :
albastru();
Serial.println("A intrat pe case 0");
break;
case 1 :
rainbow();
if(contor_break == 1){
random_effect = random(1,6);
}
else if(contor_break == 0){
random_effect = 0;
off();
delay(10);
fade_up();
}
break;
case 2 :
fade_down_roz();
if(contor_break == 1){
random_effect = random(1,6);
}
else if(contor_break == 0){
random_effect = 0;
off();
delay(10);
fade_up();
}
break;
case 3 :
fade_down_verde();
if(contor_break == 1){
random_effect = random(1,6);
}
else if(contor_break == 0){
random_effect = 0;
off();
delay(10);
fade_up();
}
break;
case 4 :
fade_down_galben();
if(contor_break == 1){
random_effect = random(1,6);
}
else if(contor_break == 0){
random_effect = 0;
off();
delay(10);
fade_up();
}
break;
case 5 :
rainbow2();
if(contor_break == 1){
random_effect = random(1,6);
}
else if(contor_break == 0){
random_effect = 0;
off();
delay(10);
fade_up();
}
break;
case 6 :
color_chase();
if(contor_break == 1){
random_effect = random(1,6);
}
else if(contor_break == 0){
random_effect = 0;
off();
delay(10);
fade_up();
}
break;
}
}
The hole code works if i comment this line but it makes no sound.
musicPlayer.playFullFile("track001.mp3");
Can you help me ? What have i done wrong and what should i change ?
And also, i have a problem, how can i change the dataPin for the led strip ? Even if i try to redefine it, it's always on pin 11. Do you have a clue about this ?