coding for the sub
Dependencies: mbed Motor Servo
main.cpp@5:9825fb56de59, 2018-10-12 (annotated)
- Committer:
- m211734
- Date:
- Fri Oct 12 11:59:48 2018 +0000
- Revision:
- 5:9825fb56de59
- Parent:
- 4:6feb04db3086
- Child:
- 7:2a445f634f19
motor switch 5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
m211734 | 0:d59f674faf5e | 1 | #include "mbed.h" |
doubleJ312 | 1:f3f36258eaab | 2 | #include "stdio.h" |
doubleJ312 | 1:f3f36258eaab | 3 | #include "stdlib.h" |
doubleJ312 | 1:f3f36258eaab | 4 | #include "Motor.h" |
doubleJ312 | 1:f3f36258eaab | 5 | #include "Servo.h" |
m211734 | 0:d59f674faf5e | 6 | /* this is the code for the sub |
m211734 | 0:d59f674faf5e | 7 | */ |
m211734 | 0:d59f674faf5e | 8 | |
m211734 | 0:d59f674faf5e | 9 | |
m211734 | 5:9825fb56de59 | 10 | #include "mbed.h" |
m211734 | 5:9825fb56de59 | 11 | #include "stdio.h" |
m211734 | 5:9825fb56de59 | 12 | #include "Motor.h" |
m211734 | 5:9825fb56de59 | 13 | |
m211734 | 5:9825fb56de59 | 14 | DigitalIn sw(p20); |
m211734 | 5:9825fb56de59 | 15 | Motor m(p26,p30,p29); |
m211734 | 0:d59f674faf5e | 16 | |
m211734 | 5:9825fb56de59 | 17 | int main(){ |
m211734 | 5:9825fb56de59 | 18 | while(1){ |
m211734 | 5:9825fb56de59 | 19 | sw.read(); |
m211734 | 5:9825fb56de59 | 20 | if (sw==1) |
m211734 | 5:9825fb56de59 | 21 | { |
m211734 | 5:9825fb56de59 | 22 | printf("motor on"); |
m211734 | 5:9825fb56de59 | 23 | m.speed(0.5); |
m211734 | 0:d59f674faf5e | 24 | } |
m211734 | 5:9825fb56de59 | 25 | else{ |
m211734 | 5:9825fb56de59 | 26 | printf("motor off"); |
m211734 | 5:9825fb56de59 | 27 | m.speed(0.0); |
m211734 | 4:6feb04db3086 | 28 | } |
m211734 | 5:9825fb56de59 | 29 | wait(0.1); |
m211734 | 5:9825fb56de59 | 30 | } |
m211734 | 5:9825fb56de59 | 31 | } |