pressure sensor trouble

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);
  }

You probably have long wires going into the arduino's analogue inputs and these are picking up electrical noise causing the miss firings.
First of all you need a diode from the input to the 5V rail to catch any over voltage and another to ground for any under voltage. Take a look at:- http://www.thebox.myzen.co.uk/Tutorial/Protection.html
The capacitor to ground will also help. The resistor needs to be much higher than shown here but not so high as the 1M you have already. Also a small capacitor on the sensor side to ground wouldn't do any harm either.

Thanks for that Mike, will give it a go first thing in the morning. Its for a big show we are putting on up here called The Fantascopic Far which is loosely based on a victorian traveling fair and suprisingly enough it has a lot of Arduino involved - 4 seperate units to be exact (mainly using arduino over midi to sequence motors, lights, fans and much more with the audio and visual content), including an RFID enabled tarot card reading wheel of fortune. Will have footage soon, but here is a link to the costume generator to which ticket buyers get re-directed to upon completion of purchase.