Multiple(at least three) force sensitive resistor setup

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.

}   // Move this bracket to the end of the program.
fsrreading = analogRead(fsrpin2);

consider

const byte PinFsr [] = { A0, A1, A2 };
const unsigned Nfsr = sizeof(PinFsr);

char        s [80];
const char *t;

// -----------------------------------------------------------------------------
void loop ()
{
    for (unsigned n = 0; n < Nfsr; n++)  {
        int fsr = analogRead (PinFsr [n]);

        if (fsr < 10)
            t = "No pressure";
        else if (fsr < 200)
            t = "Light touch";
        else if (fsr < 500)
            t = "Light squeeze";
        else if (fsr < 800)
            t = "Medium squeeze";
        else
            t = "Big squeeze";

        sprintf (s, " %6d %-18s", fsr, t);
        Serial.print (s);
    }

    Serial.println ();
    delay (500);
}

// -----------------------------------------------------------------------------
void setup ()
{
    Serial.begin (9600);
}

Thank you for the help, and I have another question do you know how to get the mass(grams)?

Calibrate your setup using some known weights, following this excellent tutorial.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.