D. Damato / Mbed 2 deprecated Exp5_FSRcalibrate

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "math.h"
00003 #include "TextLCD.h"
00004 
00005 AnalogIn FSR(p17);
00006 TextLCD lcd(p24, p26, p27, p28, p29, p30);
00007 float CalEq;
00008 
00009 int main() {
00010 
00011 // Motor RPM average initialization and index
00012     double ForceV[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
00013     int i; i = 0;
00014     
00015     while(1) {
00016     
00017     // Index and reset Motor Average Counter
00018        if(i > 9)
00019        i = 0;
00020        
00021        
00022        double FSRconst = FSR;
00023        ForceV[i] = 6.3713*pow(97.6207, FSRconst) ;          // Use AnalogIn (FSR) reading in an equation of Force versus FSR values
00024        float ForceAvg = (ForceV[0] + ForceV[1] + ForceV[2] + ForceV[3] + ForceV[4] + ForceV[5] + ForceV[6] + ForceV[7] + ForceV[8] + ForceV[9]) / 10 ;
00025        lcd.cls();
00026        lcd.locate(0, 0);
00027        lcd.printf("Calibrate FSR");
00028        lcd.locate(0, 1);
00029        lcd.printf("V=%f", ForceAvg);
00030        ++i;
00031        wait(0.25);    
00032     }
00033 }