ding
Dependencies: Encoder HIDScope mbed
Diff: main.cpp
- Revision:
- 2:ca2573919cb5
- Parent:
- 1:1709bd849df0
- Child:
- 3:8a8dc30fb08e
diff -r 1709bd849df0 -r ca2573919cb5 main.cpp --- a/main.cpp Mon Oct 27 11:18:50 2014 +0000 +++ b/main.cpp Mon Oct 27 13:38:30 2014 +0000 @@ -1,31 +1,41 @@ #include "mbed.h" #include "encoder.h" -#include "HIDScope.h" + #include <iostream> Encoder encoderA(PTD0,PTD2); PwmOut pwm(PTA5); DigitalOut dir(PTA4); -HIDScope scope(5); + + +int32_t enca = 0, encb =0; +float speed = 0.1; +int n=0,a =1 ,b =0; -float enca = 0, encb =0; -float speed; +int main() +{ + + while(1) { + + -int main(){ - - while(1){ - - cin>>speed; - pwm = 0.1; - enca = encoderA.getPosition(); - scope.set(0,pwm); - scope.set(1,enca); - scope.send(); - - wait(0.2); + enca = encoderA.getPosition(); + + + if(enca < -900) { + dir = 1; + } + if(enca > 0) { + dir = 0; + } + + pwm = 1; + cout<<"enca"<<enca<<endl; + + wait(0.1); } } - +