I have written code on the Arduino to record the pressure applied to a FSR sensor connected to pin A0. Here is my code
int pressureAnalogPin = 0; //pin where our pressure pad is located.
int pressureReading; //variable for storing our reading
bool active = false; //boolean to check whether arduino should be sending pressure values
void setup()
{
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop()
{
if (Serial.available()) //checks if data is coming in
{
char read = Serial.read(); //Set varaiable read to data read from mobile
if (read == 'g') //if read is equal to character 'g' set boolean active to true
{
active = true;
}
if (read == 'x') //if read is equal to character 'x' set boolean active to false
{
active = false;
}
}
if (active == true) //Only send data to phone when boolean active is set to true
{
pressureReading = analogRead(pressureAnalogPin); // Set varaible pressureReading to the pressure value recorded by FSR
Serial.print(pressureReading); //Send pressure value to mobile phone
}
delay(100);// a delay of 100ms in loop
}
I receive results from 0 to 1023. I have conducted an experiment, by incrementing weights on top of the pressure sensor.
Above is an excel chart showing the increase in weight and the pressure recorded.
Can someone let me know what is the unit is for these pressure readings?