D. Damato
/
Exp5_FSRcalibrate
Exp5_FSRcalibrate
Diff: main.cpp
- Revision:
- 0:a7fdac873af3
- Child:
- 1:37707fc10edc
diff -r 000000000000 -r a7fdac873af3 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Aug 02 19:25:21 2011 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +#include "TextLCD.h" + +AnalogIn FSR(p17); +TextLCD lcd(p24, p26, p27, p28, p29, p30); +float CalEq; + +int main() { + +// Motor RPM average initialization and index + float ForceV[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + int i; i = 0; + + while(1) { + + // Index and reset Motor Average Counter + if(i > 9) + i = 0; + + + CalEq = 1.0; + ForceV[i] = FSR*CalEq; // Use AnalogIn (FSR) reading in an equation of Force versus FSR values + float ForceAvg = (ForceV[0] + ForceV[1] + ForceV[2] + ForceV[3] + ForceV[4] + ForceV[5] + ForceV[6] + ForceV[7] + ForceV[8] + ForceV[9]) / 10 ; + lcd.cls(); + lcd.locate(0, 0); + lcd.printf("Calibrate FSR"); + lcd.locate(0, 1); + lcd.printf("V=%f", ForceAvg); + ++i; + wait(0.25); + } +}