elevator
/
Elevator_movement_proportional
proportional
Diff: main.cpp
- Revision:
- 0:37a74423d68e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Feb 19 14:31:05 2015 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" +#include "Motor.h" +Serial pc(USBTX,USBRX);//allows communication through the USB +AnalogIn range(p19); +float height; +float rv; +float dh; +float ds; +float er; +float k=0.15; +Motor m(p26, p29, p30); +int main() +{ + + m.speed(0); + while(1){ + rv=range; + height=(-75.7457492123552*pow(rv,2))+(90.6774745565381*rv)+(-4.00358328437282); + pc.printf("%f,%f\n",rv,height); + pc.printf("Enter desired height\n"); + pc.scanf("%f",&dh); + er=dh-height; + ds=k*er; + m.speed(ds); + + + + } + } \ No newline at end of file