Hi,
I am using an Arduino UNO and a Seeedstudio Music Shield (
http://seeedstudio.com/wiki/Music_Shield) to run a very simple project, which is giving me some problems anyway.. Basically, when someone is close enough to a proximity sensor (Analog5), a stored sound file should start playing. The file would play till the end (2.30 min), then the arduino would wait some time and start the process again so that the next person that comes in will enjoy the same treat.
You have to imagine that the sensor is in front of a mirror and the file plays only (but for all it's length) when someone approches it.. Of course this is quite hard cause if someone will remain in front of the mirror for longer time then the file will play again... but that is part of the game I guess.
Here is my code. At the moment I can get the file to play when the sensor goes under a threshold but then it won't play again a second time.. the process kind of freezes it self after a first reproduction. ..thanks a lot!!
#include <avr/io.h>
#include "config.h"
#include "filesys.h"
#include "player.h"
#include "vs10xx.h"
#include "record.h"
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //pin2-Rx,pin3-Tx(note: pin3 is actually later used as volume down input)
const int analogPin = A5;
const int ledPin = 1;
const int threshold = 400;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
InitSPI();
InitIOForVs10xx();
InitIOForKeys();
InitIOForLEDs();
InitFileSystem();
//VsSineTest();
Mp3Reset();
}
void loop() {
int proximityValue = analogRead(analogPin);
Serial.println(proximityValue);
if (proximityValue > threshold) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
Play();
}
}