![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
working
main.cpp@1:214c872ef845, 2014-10-16 (annotated)
- Committer:
- m175694
- Date:
- Thu Oct 16 14:21:46 2014 +0000
- Revision:
- 1:214c872ef845
- Parent:
- 0:833afd26d33b
final motor code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
m175694 | 0:833afd26d33b | 1 | #include "mbed.h" |
m175694 | 0:833afd26d33b | 2 | #include "Motor.h" |
m175694 | 1:214c872ef845 | 3 | float motspeed=.3; |
m175694 | 1:214c872ef845 | 4 | int count = 0; |
m175694 | 1:214c872ef845 | 5 | int notdone=1; |
m175694 | 1:214c872ef845 | 6 | int i; |
m175694 | 1:214c872ef845 | 7 | int count2 = 0; |
m175694 | 1:214c872ef845 | 8 | DigitalIn sw1(p16); |
m175694 | 0:833afd26d33b | 9 | int main() |
m175694 | 0:833afd26d33b | 10 | { |
m175694 | 0:833afd26d33b | 11 | Motor m(p26,p29,p30); |
m175694 | 0:833afd26d33b | 12 | |
m175694 | 1:214c872ef845 | 13 | |
m175694 | 0:833afd26d33b | 14 | while(1) { |
m175694 | 1:214c872ef845 | 15 | while (count < 10 && sw1 !=0) { |
m175694 | 1:214c872ef845 | 16 | m.speed(motspeed); |
m175694 | 1:214c872ef845 | 17 | wait(.08); |
m175694 | 0:833afd26d33b | 18 | m.speed(0.0); |
m175694 | 1:214c872ef845 | 19 | wait(.3); |
m175694 | 1:214c872ef845 | 20 | count ++; |
m175694 | 1:214c872ef845 | 21 | } |
m175694 | 1:214c872ef845 | 22 | while (count2 < 10 && sw1 !=0) { |
m175694 | 1:214c872ef845 | 23 | m.speed(-motspeed); |
m175694 | 1:214c872ef845 | 24 | wait(.08); |
m175694 | 1:214c872ef845 | 25 | m.speed(0.0); |
m175694 | 1:214c872ef845 | 26 | wait(.3); |
m175694 | 1:214c872ef845 | 27 | count2 ++; |
m175694 | 0:833afd26d33b | 28 | |
m175694 | 1:214c872ef845 | 29 | } |
m175694 | 1:214c872ef845 | 30 | count=0; |
m175694 | 1:214c872ef845 | 31 | count2=0; |
m175694 | 1:214c872ef845 | 32 | if(sw1==0) { |
m175694 | 0:833afd26d33b | 33 | |
m175694 | 0:833afd26d33b | 34 | } |
m175694 | 0:833afd26d33b | 35 | |
m175694 | 0:833afd26d33b | 36 | } |
m175694 | 1:214c872ef845 | 37 | |
m175694 | 0:833afd26d33b | 38 | } |
m175694 | 1:214c872ef845 | 39 | |
m175694 | 1:214c872ef845 | 40 | |
m175694 | 1:214c872ef845 | 41 | |
m175694 | 1:214c872ef845 | 42 | |
m175694 | 1:214c872ef845 | 43 | |
m175694 | 1:214c872ef845 | 44 | |
m175694 | 1:214c872ef845 | 45 | |
m175694 | 1:214c872ef845 | 46 | |
m175694 | 1:214c872ef845 | 47 |