Hi I’m currently working on a project where I am trying to get 3 force resistor sensors, to show their input results at the same time. I've tried to get this to work with two first, this has been done using a void loop and a while statement. However this will only show 1 fsr result then show the rest from the other sensor. I want to get it to continually show both sensors result. Below is the code I am working with.
//Declaring resistors
//Resistor 1
int fsrPin = 0; // Resistor connectected to A0
int fsrReading; // Anolog reading from resistor 1
//Resistor 2
int fsrPin1 = 1; // Resistor connectected to A1
int fsrReading1; // Anolog reading from resistor 2
//Resistor 3
int fsrPin2 = 2; // Resistor connectected to A2
int fsrReading2; // Anolog reading from resistor 3
void setup(void) {
// debugging information sent to the serial monitor
Serial.begin(9600);
Serial.println("Testing left right and centre pressure sesnors");
}
//Loop the sequence, so that results are always showing
void loop (void) {
fsrReading = analogRead(fsrPin);//analog reading for resistor 1 = seting to sensor 1
Serial.print("Sensor 1 = "); //what will be displayed before the result
Serial.print(fsrReading); // the raw analog reading
//determinations of pressure
if (fsrReading < 10) {
Serial.println(" - No pressure");
//under 10 = no pressure
} else if (fsrReading < 200) {
Serial.println(" - Faint Pressure");
//11 to under 200 = faint pressure
} else if (fsrReading < 500) {
Serial.println(" - Light pressure");
//201 to under 500 = Light pressure
} else if (fsrReading < 800) {
Serial.println(" - Medium pressure");
//501 to under 800 = Medium pressure
} else {
Serial.println(" - Large pressure");
//above 800 = large pressure
}
delay(1000);//time delay between each result
while(1){//while loop should read sensor 2 while looping sesnor 1
fsrReading1 = analogRead(fsrPin1);
Serial.print("Sensor 2 = ");
Serial.print(fsrReading1); // the raw analog reading
//determinations of pressure
if (fsrReading1 < 10) {
Serial.println(" - No pressure");
//under 10 = no pressure
} else if (fsrReading1 < 200) {
Serial.println(" - Faint pressure");
//11 to under 200 = faint pressure
} else if (fsrReading1 < 500) {
Serial.println(" - Light pressure");
//201 to under 500 = Light pressure
} else if (fsrReading1 < 800) {
Serial.println(" - Medium pressure");
//501 to under 800 = Medium pressure
} else {
Serial.println(" - Large pressure");
//above 800 = large pressure
}
delay(1000);//time delayed between new readings
}
}