For a project at school I need to program an Arduino such that three independent Force Sensitive Resistors are each represented with an individual line in the serial plotter. I don't have any experience with plotting multiple outcomes of calculations, so please don't be too harsh. If I plot the outputs now, it thinks that all the values should be represented with one single line in the plot and that's not what I want. I want three individual lines each representing a different force measured from the three different FSR's. Could you guys help me?
Here's the code so far:
const int FSR_PIN1 = A0; // Pin connected to FSR1
const int FSR_PIN2 = A1; // Pin connected to FSR2
const int FSR_PIN3 = A2; // Pin connected to FSR3
const float VCC = 4.98; // Measured voltage of Ardunio 5V line
const float R_DIV = 1000.00; // resistance of a 1k ohm resistor
void setup(){
Serial.begin(9600);
pinMode(FSR_PIN1, INPUT); //set the pins as inputs
pinMode(FSR_PIN2, INPUT);
pinMode(FSR_PIN3, INPUT);
}
void loop(){
int fsrAR1 = analogRead(FSR_PIN); // We need the analogRead from the pins to calculate voltage, because they are force sensitive resistors
int fsrAR2 = analogRead(FSR_PIN2);
int fsrAR3 = analogRead(FSR_PIN3);
if (fsrAR1 !=0) { //when the reading is not zero, give an output
float fsrV = fsrAR * VCC / 1023.0; // Use Analog reading to calculate voltage:
float force = (303.71*(fsrVfsrV))-(143.47fsrV)+34.124; // calculate force using a voltage-force graph from the manufacturer of the fsr
Serial.println(force);
Serial.print(" ");
}
if (fsrAR2 !=0) { //when the reading is not zero, give an output
float fsrV2 = fsrAR2 * VCC / 1023.0; // Use Analog reading to calculate voltage:
float force2 = (303.71*(fsrV2fsrV2))-(143.47fsrV2)+34.124; // calculate force using a voltage-force graph from the manufacturer of the fsr
Serial.println(force2);
Serial.print(" ");
}
if (fsrAR3 !=0) { //when the reading is not zero, give an output
float fsrV3 = fsrAR3 * VCC / 1023.0; // Use Analog reading to calculate voltage:
float force3 = (303.71*(fsrV3fsrV3))-(143.47fsrV3)+34.124; // calculate force using a voltage-force graph from the manufacturer of the fsr
Serial.println(force3);
Serial.print(" ");
delay(5); //to stabilize
}
else{
}
}