Buenos días.
Llevo bastante tiempo leyéndoos y adentrándome en el mundo "Arduino". Tengo un proyecto personal en curso que consiste en hacer una caja musical con un módulo y arduino.
Estoy empezando a usar el módulo y por tanto voy "por partes" para, primero, ver que funciona correctamente. Actualmente no oigo nada (ayer conseguí oir - bajito - algo pero al hacer otro montaje y volver a éste, ya no se oía), no sé si me falta algo o tengo algo mal conectado. Os pongo todos los datos:
Material usado:
Arduino Pro Micro
SparkFun Audio-Sound Breakout - WTV020SD + tarjeta SD 2GB
Pila de 9V
Reductor tensión a 3,3V
Cables
Interruptor
Canción grabada en ad4 con nombre 0000.ad4 (convertida con el Audio Converter Utility de la página de Sparkfun)
Código utilizado
/*
WTV020-SD-16P Test
Control a WTV020-SD-16P module to play sounds from an Arduino board.
Created July 2012.
By Diego J. Arevalo.
*/
const int resetPin = 10; // The pin number of the reset pin.
const int clockPin = 9; // The pin number of the clock pin.
const int dataPin = 6; // The pin number of the data pin.
const int busyPin = 5; // The pin number of the busy pin.
int busyPinState = HIGH;
void setup() {
pinMode(resetPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(busyPin, INPUT);
resetModule();
}
void loop() {
playSong(0);
delay(5);
}
void playSong(int trackNumber){
sendCommand(trackNumber);
busyPinState=digitalRead(busyPin);
while(busyPinState==HIGH){
busyPinState=digitalRead(busyPin);
}
}
void resetModule(){
//Reset pulse.
digitalWrite(resetPin, HIGH);
digitalWrite(resetPin, LOW);
delay(5);
digitalWrite(resetPin, HIGH);
//Reset idle to start bit.
digitalWrite(clockPin,HIGH);
delay(300);
}
void sendCommand(unsigned int command) {
//Start bit Low level pulse.
digitalWrite(clockPin, LOW);
delay(2);
for (unsigned int mask = 0x8000; mask > 0; mask >>= 1) {
//Write data setup.
if (command & mask) {
digitalWrite(dataPin, HIGH);
}
else {
digitalWrite(dataPin, LOW);
}
//Write data hold.
delayMicroseconds(50);
//Clock high level pulse.
digitalWrite(clockPin, HIGH);
if (mask > 0x0001){
delayMicroseconds(100);
//Clock low level pulse.
digitalWrite(clockPin, LOW);
delayMicroseconds(100);
}
else{
//Stop bit high level pulse.
delay(2);
digitalWrite(clockPin, LOW);
}
}
//Busy active high from last data bit latch.
delay(20);
}
¿Alguna idea/ayuda de dónde puede estar el fallo?
¡Gracias!
Edito: después de un tiempo probando cosas, desmontarlo y volver a montarlo, resulta que se oye.
Pero lo desenchufo (quito alimentación), vuelvo a enchufar y ya no se oye nada...
alguna idea??