// Flexiforce quick start example // Reads A0 every 100ms and sends voltage value over serial //delay int holdseconds = 2000; //after 2 sec you have to press it again to let it work //timer sensor 1 int oldval1 = 0; long millisStart1 = 0; bool pressed1 = false; //timer sensor 2 int oldval2 = 0; long millisStart2 = 0; bool pressed2 = false; //timer sensor 3 int oldval3 = 0; long millisStart3 = 0; bool pressed3 = false; void setup() { // Start serial at 9600 baud Serial.begin(9600); } void loop() { //value when he thinks the sensor is pressed int threshold = 499; // Read the input on analog pin 0: int sensorValue1 = analogRead(A0); //delta high if (oldval1 < threshold && sensorValue1 > threshold) { millisStart1 = millis(); pressed1 = true; } else if (oldval1 > threshold && sensorValue1 < threshold) { pressed1 = false; } if (millis() - millisStart1 > holdseconds) pressed1 = false; oldval1 = sensorValue1; if (pressed1) Serial.print(sensorValue1); else Serial.print(0); Serial.print(","); // Read the input on analog pin 1: int sensorValue2 = analogRead(A1); //delta high if (oldval2 < threshold && sensorValue2 > threshold) { millisStart2 = millis(); pressed2 = true; } else if (oldval2 > threshold && sensorValue2 < threshold) { pressed2 = false; } if (millis() - millisStart2 > holdseconds) pressed2 = false; oldval2 = sensorValue2; if (pressed2) Serial.print(sensorValue2); else Serial.print(0); Serial.print(","); // Read the input on analog pin 0: int sensorValue3 = analogRead(A2); //delta high if (oldval3 < threshold && sensorValue3 > threshold) { millisStart3 = millis(); pressed3 = true; } else if (oldval3 > threshold && sensorValue3 < threshold) { pressed3 = false; } if (millis() - millisStart3 > holdseconds) pressed3 = false; oldval3 = sensorValue3; if (pressed3) Serial.print(sensorValue3); else Serial.print(0); Serial.println(); //ga naar nieuwe regel. delay(50); }