I'm a 4th year student working on an individual project, basically i want to connect multiple 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 two, 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 Elgoo uno R3 board, windows 10 and the Arduino IDE software, the code is attached to this document and the error message received is that the second fsrreading does not name a type.
#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.
In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless
If the code exceeds the 9000 character inline limit then attach it to a post