Threshold Problem

So, to explain this as simple as possible, I am using a flora board and 2 piezo microphones. I want to make a program and device that will only record with one piezo at first. There is a threshold. When any noises picked up by the piezo go over the threshold, a counter is added to an array of ints called timeStamp. When the array becomes full the piezo recording will turn off and the other piezo will turn on. once it turns on it will play a noise for each spot filled in the array. Right now I am debbuging the code by using the on board LED on the flora board (pin 7). When the noise that the first piezo picks up is over the threshold the on board LED will turn on.

My problem is that when I check the serial monitor, the values that the first piezo picks up are already over the threshold. This happens no matter what value I change the threshold too. How can I fix this?

I have also attatched the .ino file to this post.

const int analogInPin = 6;
const int ledPin = 7;
int currentVal = 0;
int preVal = 0;

int timeStamp [6];

int threshold = 12;

int sensorValue = 0;
int outputValue = 0;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop() {

  sensorValue = analogRead(analogInPin);
  currentVal = sensorValue;
  Serial.print("sensor = ");
  Serial.println(sensorValue);
  //if ((currentVal > preVal) && (currentVal > threshold)) {
  if (currentVal > threshold) {
    digitalWrite (ledPin, HIGH);
    Serial.print("hit = ");
    Serial.println(sensorValue);
    delay(100);
  } else {
    digitalWrite (ledPin, LOW);
  }
  preVal = currentVal;
  delay(2);

}

sketch_may11a.ino (671 Bytes)

const int analogInPin = 6;I don't have a Flora, so I don't know, but how many analogue inputs does it have?

well, the pins that I can use to write data too are pins 6,9,10,12. There is 2 GND pins, 2 3.3V pins (at least these are all of the relevant pins right now)

well, the pins that I can use to write data too are pins 6,9,10,12.

So what? You aren't trying to write data to the pin with the piezo sensor attached to it.

He asked for the analouge inputs, he is asking for the pins no?

No analog 6 visible here FLORA pinout diagram | Getting Started with FLORA | Adafruit Learning System
There is a digital 6 that doubles as analog 7.

@AWOL there is 4 analogue inputs

Raiz:
He asked for the analouge inputs, he is asking for the pins no?

He is asking you to make sure that 6 is a valid pin number, for an analog pin.

Ahh ok, I just got more of an understanding of what an analogue input is. Im new to all of this