Elevator
/
Elevator
The first code
main.cpp
- Committer:
- m172886
- Date:
- 2015-02-12
- Revision:
- 3:7b0316e7cabc
- Parent:
- 2:559b5507c580
- Child:
- 4:059832a0c7b9
File content as of revision 3:7b0316e7cabc:
#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,",height); pc.printf("%f,",ain.read()); //this prints the voltage pc.printf("%f",t.read()); pc.printf("\n"); } }