hello
I am having some issues with a series of pressure sensors and Arduino. The pressure sensors are designed for an intruder alarm system and are usually installed under a carpet. They work just like a piezo knock sensor and I want to use them in an interactive installation walk through piece where the user triggers events as they pass through a space. The trouble is that they constantly mis-fire, i.e. just trigger themselves and no matter how much i tweak the threshold in the code they still do it. As is usual with such a project and the impending deadline (26th of september) they have chosen to misbehave at a very inopportune moment. I built a unit which has a series of SSR's connected to the digital pins of the arduino with the sensors connected to the analogue pins through a 1-megohm resistor (I also need the code to output a midi signal when the sensors are triggered to control the audio of the piece). I am not sure how to proceed, I have tried a few different ratings resistors but anything about a 1-megohm resistors is too much and the sensors stop working all together. Anyone have much experience with this? I think the problem is an electrical one rather than the code, but neither of these fields is a speciality of mine, so any help / suggestions would be greatly appreciated. I have included my code below.
Thanks for your time.
/* Knock Sensor
* ----------------
*
* Program using a Piezo element as if it was a knock sensor.
*
* We have to basically listen to an analog pin and detect
* if the signal goes over a certain threshold. If the Threshold
* is crossed, and toggles the LED on pin 13.
*
* Modified from one by (cleft) 2005 D. Cuartielles for K3
*/
int delay_time = 40;
int ledPin = 11;
int ledPin1 = 7;
int knockSensor1 = 0;
int knockSensor2 = 2;
byte val = 0;
int statePin = LOW;
int THRESHOLD = 200;
int THRESHOLD1 = 116;// if it's too sensitive then change this value
int SERIAL_PORT_RATE = 31250;
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(SERIAL_PORT_RATE);
}
void loop()
{
val = analogRead(knockSensor1);
if (val >= THRESHOLD) { // check the piezo
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);}
if (val >= THRESHOLD)
{midiOUT(0x90, 65, 127);
// turn on or off the LED
}
val = analogRead(knockSensor2);
if (val >= THRESHOLD1) { // check the piezo
digitalWrite(ledPin1, HIGH);
delay(100);
digitalWrite(ledPin1, LOW);}
if (val >= THRESHOLD1)
{midiOUT(0x90, 66, 127);
// turn on or off the LED
}
delay(delay_time);
}
void midiOUT(char command, char value1, char value2){
Serial.print(command, BYTE);
Serial.print(value1, BYTE);
Serial.print(value2, BYTE);
}