Hi,
I'm a High school student working on an individual project, basically, I want to connect multiple(three) force-sensitive resistors and receive feedback from each of them. I have successfully managed to use a singular FSR, however, when I try to connect three, I am getting error messages in my half-written half copied code (surprise) and was wondering if anyone could help. Currently, I have two FSRs connected and both have been tested to ensure they and the wiring are working.
I am using an Arduino uno R3 board, windows 11, and the Arduino IDE software.
Any help is much appreciated.
here is the code:
#define fsrpin A0
#define fsrpin2 A1
//Define variable to store sensor readings:
int fsrreading;
int fsrreading2;
//Variable to store FSR value
void setup() {
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
}
void loop() {
// Read the FSR pin and store the output as fsrreading:
fsrreading = analogRead(fsrpin);
// Print the fsrreading in the serial monitor:
// Print the string "Analog reading = ".
Serial.print("Analog reading = ");
// Print the fsrreading:
Serial.print(fsrreading);
// We can set some threshholds to display how much pressure is roughly applied:
if (fsrreading < 10) {
Serial.println(" - No pressure");
} else if (fsrreading < 200) {
Serial.println(" - Light touch");
} else if (fsrreading < 500) {
Serial.println(" - Light squeeze");
} else if (fsrreading < 800) {
Serial.println(" - Medium squeeze");
} else {
Serial.println(" - Big squeeze");
}
}
fsrreading = analogRead(fsrpin2);
// Print the fsrreading in the serial monitor:
// Print the string "Analog reading = ".
Serial.print("Analog reading = ");
// Print the fsrreading:
Serial.print(fsrreading2);
// We can set some threshholds to display how much pressure is roughly applied:
if (fsrreading < 10) {
Serial.println(" - No pressure");
} else if (fsrreading < 200) {
Serial.println(" - Light touch");
} else if (fsrreading < 500) {
Serial.println(" - Light squeeze");
} else if (fsrreading < 800) {
Serial.println(" - Medium squeeze");
} else {
Serial.println(" - Big squeeze");
}
delay(500); //Delay 500 ms.