![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
The first code
Diff: main.cpp
- Revision:
- 3:7b0316e7cabc
- Parent:
- 2:559b5507c580
- Child:
- 4:059832a0c7b9
--- a/main.cpp Thu Feb 05 15:15:47 2015 +0000 +++ b/main.cpp Thu Feb 12 16:31:56 2015 +0000 @@ -1,20 +1,32 @@ #include "mbed.h" #include "time.h" +#include "Motor.h" AnalogIn ain(p17); Serial pc(USBTX, USBRX); Timer t; +Motor m(p25,p27,p28); +float height; +float Lower_distance = 7; // lower floor in inches. + +float Upper_distance = 26; // upper floor in inches + +float Desired_distance = Lower_distance; // start low int main(void) { t.reset(); //reset timer to zero t.start(); //start timer data timestamp + m.speed(0.0); while(1) { +height = 193.125176919012*(pow(ain.read(),3))-353.927724612106*(pow(ain.read(),2))+218.749286479109*(ain.read())-23.2532105680997; pc.baud(9600); pc.format(7,SerialBase::None,1); - pc.printf("%f",ain.read()); //this prints the voltage - pc.printf("%f,",t.read()); + pc.printf("%f,",height); + pc.printf("%f,",ain.read()); //this prints the voltage + pc.printf("%f",t.read()); pc.printf("\n"); + } }