D. Damato
/
Exp5_FSRcalibrate
Exp5_FSRcalibrate
main.cpp
- Committer:
- ddamato31
- Date:
- 2011-08-03
- Revision:
- 1:37707fc10edc
- Parent:
- 0:a7fdac873af3
File content as of revision 1:37707fc10edc:
#include "mbed.h" #include "math.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 double 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; double FSRconst = FSR; ForceV[i] = 6.3713*pow(97.6207, FSRconst) ; // 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); } }