Hello,
I have a group of data, in which a specific voltage relate to a specific weight, for example 2 volts is almost 1.5kg.
In my prgram, I have mapped the analog input reading, which reads the weight applied to the FSR, to the voltage (0 to 5000mV). So, now I am wondering, can I use a loopup table which will find a specific voltage, and then print out the correspinding weight?
I have never used lookup takes and would really like some advice, because I could completely be heading down the worng paths.
Here is what I have so far, which may make things a bit clearer ...but there is no table in it yet.
int analogPin = 0;
int fsrReading;
int fsrVoltage;
long forForce;
void setup()
{
Serial.begin(9600);
pinMode(analogPin, INPUT);
}
void loop()
{
fsrReading = analogRead(analogPin);
if(fsrReading == 0)
{
;;
}
else
{
fsrReading = analogRead(analogPin);
//Analog value ranges from 0 to 1023, or 1 to 5000mV
fsrVoltage = map(fsrReading, 0, 1023, 0, 5000);
Serial.println("The voltage is: ");
Serial.println(fsrVoltage);
delay(1000);
}
}
Thanks in advance.
Seán