/* Threshold Trigger
 * Jeff Gray - 2008
 * ----------------
 * Triggers a one time event when value goes over threshold,
 * and a different trigger once the value goes back below the threshold
 */

int threshold = 400;
boolean triggered = false;

void setup(){
  Serial.begin(19200);
  Serial.println("Starting");
}
void loop(){
  // read analog value in
  int analogIn = analogRead(0);

  if(analogIn > threshold && !triggered){
    triggered = true;
    Serial.println("Triggered");
  }
  if(analogIn <= threshold && triggered){
    triggered = false;
    Serial.println("Trigger Off");
  }

  delay(50);
}