Elevator
/
Elevator
The first code
Diff: main.cpp
- Revision:
- 4:059832a0c7b9
- Parent:
- 3:7b0316e7cabc
- Child:
- 5:47d6ae63a1a3
--- a/main.cpp Thu Feb 12 16:31:56 2015 +0000 +++ b/main.cpp Thu Feb 12 16:42:25 2015 +0000 @@ -6,6 +6,7 @@ Serial pc(USBTX, USBRX); Timer t; Motor m(p25,p27,p28); +float error = Desired_distance - height; float height; float Lower_distance = 7; // lower floor in inches. @@ -27,6 +28,14 @@ pc.printf("%f,",ain.read()); //this prints the voltage pc.printf("%f",t.read()); pc.printf("\n"); - + if (error > 0) + { + m.speed(0.5); + } + else(error<0) + { + m.speed(-0.5) + } } + }