Hi there,
we recently opened up an exhibition which does also have some Arduino-based interactive samples. One of them is an old phone booth which stands on a base in which a pair of speakers and an in-wall motion sensor (like the ones found on normal house lights) were mounted. We have an Arduino plus Waveshield, and what happens is that if someone's walking by the booth, a sound is played.
Since the motion sensors work on 240V, we used a relais to "connect" it to the Arduino. So what happens is that as soon as the motion sensors detects movement, he allows the current to pass, triggering the relais which then allows another current from/to the Arduino to pass.
We connected one digitalout with another through that relais, whereas the "input" pin is also connected to GND via a resistor (puldown). We tried it out and it worked like a charm. Now that the booth is "out in the wild", we found out that the Arduino stops working after a couple of hours.
It's really hard to find the problem since I can't sit next to it four hours with my computer connected just to wait until it doesn't work anymore and see if there's an error message on the Serial port. I also can't leave my computer there because it's arranged in a public space. So maybe someone here has an idea what could be the problem (already tried another Arduino and/or Waveshield).
Here's a very rough version of the wiring (sorry, not really experienced with this) as well as the code. The code does run through all the files, I checked that. But at some point, it just doesn't work anymore...
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"
//Variables for Audio...
long lastAction = 0;
long pauseBetweenActions = 30000; //ms before another sound is triggered
int in1 = 9;
int out1 = 7;
int playIndex = 0;
void setup() {
pinMode(in1, INPUT);
pinMode(out1, OUTPUT);
//pinMode(13, OUTPUT);
digitalWrite(out1, HIGH);
//Audio setup goes here...
}
void loop() {
delay(300);
if(millis() - lastAction > pauseBetweenActions) {
if(digitalRead(in1) == HIGH) {
switch(playIndex) {
case 0:
playfile("ruf_01.wav");
break;
case 1:
playfile("ruf_02.wav");
break;
case 2:
playfile("ruf_03.wav");
break;
case 3:
playfile("ruf_04.wav");
break;
case 4:
playfile("ruf_05.wav");
break;
case 5:
playfile("ruf_06.wav");
break;
case 6:
playfile("ruf_07.wav");
break;
case 7:
playfile("ruf_08.wav");
break;
case 8:
playfile("ruf_09.wav");
break;
case 9:
playfile("ruf_10.wav");
break;
}
lastAction = millis();
playIndex++;
if(playIndex == 10)
playIndex = 0;
//playIndex = (playIndex == 4 ? 0:playIndex++);
}
}
}
void playfile(char *name) {
//...play the file
}
Thanks for your suggestions,
Markus