Exp5_FSRcalibrate

Dependencies:   TextLCD mbed

main.cpp

Committer:
ddamato31
Date:
2011-08-02
Revision:
0:a7fdac873af3
Child:
1:37707fc10edc

File content as of revision 0:a7fdac873af3:

#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);    
    }
}