Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@6:477382219bcf, 2019-03-26 (annotated)
- Committer:
- mazdo25
- Date:
- Tue Mar 26 16:19:47 2019 +0000
- Revision:
- 6:477382219bcf
- Parent:
- 5:f1613df66ceb
- Child:
- 7:cb07cdb35b6c
LATEST WORKING
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mazdo25 | 1:813f4b17ae65 | 1 | #define PI 3.141 |
mazdo25 | 1:813f4b17ae65 | 2 | |
mazdo25 | 1:813f4b17ae65 | 3 | #include "math.h" |
mazdo25 | 0:f45212966fb1 | 4 | #include "mbed.h" |
mazdo25 | 0:f45212966fb1 | 5 | #include "Encoder.h" |
mazdo25 | 3:01b5e80d842d | 6 | #include "lineSensor.h" |
mazdo25 | 5:f1613df66ceb | 7 | #include "PID2.h" |
mazdo25 | 4:208f5279143a | 8 | #include "PID.h" |
mazdo25 | 5:f1613df66ceb | 9 | #include "Wheel.h" |
mazdo25 | 1:813f4b17ae65 | 10 | #include "Robot.h" |
mazdo25 | 1:813f4b17ae65 | 11 | |
mazdo25 | 0:f45212966fb1 | 12 | |
mazdo25 | 0:f45212966fb1 | 13 | //blue D8 |
mazdo25 | 0:f45212966fb1 | 14 | //Green D9 |
mazdo25 | 0:f45212966fb1 | 15 | //Red D5 |
mazdo25 | 3:01b5e80d842d | 16 | int main() { |
mazdo25 | 6:477382219bcf | 17 | char c; |
mazdo25 | 6:477382219bcf | 18 | //Serial hm10(PA_11, PA_12); |
mazdo25 | 6:477382219bcf | 19 | //hm10.baud(9600); |
mazdo25 | 1:813f4b17ae65 | 20 | |
mazdo25 | 3:01b5e80d842d | 21 | DigitalOut enable(PA_13); |
mazdo25 | 3:01b5e80d842d | 22 | enable.write(1); |
mazdo25 | 3:01b5e80d842d | 23 | |
mazdo25 | 1:813f4b17ae65 | 24 | Encoder* RE = new Encoder(PB_3,PB_5); |
mazdo25 | 3:01b5e80d842d | 25 | Encoder* LE = new Encoder(PB_10,PB_4); |
mazdo25 | 5:f1613df66ceb | 26 | Wheel* leftWheel = new Wheel(LE,PC_8,PA_9, PA_14); |
mazdo25 | 5:f1613df66ceb | 27 | Wheel* rightWheel = new Wheel(RE,PC_6,PA_8, PA_7); |
mazdo25 | 0:f45212966fb1 | 28 | |
mazdo25 | 4:208f5279143a | 29 | //an array of lineSensor pointers params: lineSensor(PinName emitter Pin, PinName reciever Pin, make sure it is from LEFT TO RIGHT |
mazdo25 | 4:208f5279143a | 30 | lineSensor* sensorArray[6] = {new lineSensor(PB_9,A0),new lineSensor(PC_11,A1),new lineSensor(PD_2,A2),new lineSensor(PC_10,A3),new lineSensor(PB_8,A4),new lineSensor(PC_12,A5)}; |
mazdo25 | 4:208f5279143a | 31 | |
mazdo25 | 6:477382219bcf | 32 | leftWheel->init2(); |
mazdo25 | 0:f45212966fb1 | 33 | |
mazdo25 | 6:477382219bcf | 34 | rightWheel->init2(); |
mazdo25 | 5:f1613df66ceb | 35 | |
mazdo25 | 5:f1613df66ceb | 36 | Robot rbt(leftWheel, rightWheel, sensorArray); |
mazdo25 | 6:477382219bcf | 37 | |
mazdo25 | 6:477382219bcf | 38 | rbt.rbtInit(); |
mazdo25 | 3:01b5e80d842d | 39 | while(1) |
mazdo25 | 3:01b5e80d842d | 40 | { |
mazdo25 | 6:477382219bcf | 41 | |
mazdo25 | 3:01b5e80d842d | 42 | } |
mazdo25 | 3:01b5e80d842d | 43 | } |
mazdo25 | 6:477382219bcf | 44 | |
mazdo25 | 6:477382219bcf | 45 | /* |
mazdo25 | 6:477382219bcf | 46 | if(hm10.readable()) |
mazdo25 | 6:477382219bcf | 47 | { |
mazdo25 | 6:477382219bcf | 48 | c = hm10.getc(); |
mazdo25 | 6:477382219bcf | 49 | if(c=='R') |
mazdo25 | 6:477382219bcf | 50 | { |
mazdo25 | 6:477382219bcf | 51 | |
mazdo25 | 6:477382219bcf | 52 | } |
mazdo25 | 6:477382219bcf | 53 | else if(c=='F') |
mazdo25 | 6:477382219bcf | 54 | { |
mazdo25 | 6:477382219bcf | 55 | |
mazdo25 | 6:477382219bcf | 56 | } |
mazdo25 | 6:477382219bcf | 57 | } |
mazdo25 | 6:477382219bcf | 58 | */ |