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.
main.cpp@0:68efaf4d1fa6, 2017-03-23 (annotated)
- Committer:
- CamJohnston
- Date:
- Thu Mar 23 11:38:29 2017 +0000
- Revision:
- 0:68efaf4d1fa6
Elec1130 Buggy
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CamJohnston | 0:68efaf4d1fa6 | 1 | #include "mbed.h" |
CamJohnston | 0:68efaf4d1fa6 | 2 | AnalogIn Up(p16); |
CamJohnston | 0:68efaf4d1fa6 | 3 | AnalogIn Down(p17); |
CamJohnston | 0:68efaf4d1fa6 | 4 | AnalogIn Right(p18); |
CamJohnston | 0:68efaf4d1fa6 | 5 | AnalogIn Left(p19); |
CamJohnston | 0:68efaf4d1fa6 | 6 | |
CamJohnston | 0:68efaf4d1fa6 | 7 | DigitalOut RightUp(p24); |
CamJohnston | 0:68efaf4d1fa6 | 8 | DigitalOut RightDown(p23); |
CamJohnston | 0:68efaf4d1fa6 | 9 | DigitalOut LeftUp(p22); |
CamJohnston | 0:68efaf4d1fa6 | 10 | DigitalOut LeftDown(p21); |
CamJohnston | 0:68efaf4d1fa6 | 11 | |
CamJohnston | 0:68efaf4d1fa6 | 12 | |
CamJohnston | 0:68efaf4d1fa6 | 13 | int main() |
CamJohnston | 0:68efaf4d1fa6 | 14 | { |
CamJohnston | 0:68efaf4d1fa6 | 15 | while(1) { |
CamJohnston | 0:68efaf4d1fa6 | 16 | if (Up.read() > 0.83) { |
CamJohnston | 0:68efaf4d1fa6 | 17 | RightUp.write(1); |
CamJohnston | 0:68efaf4d1fa6 | 18 | RightDown.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 19 | LeftUp.write(1); |
CamJohnston | 0:68efaf4d1fa6 | 20 | LeftDown.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 21 | } |
CamJohnston | 0:68efaf4d1fa6 | 22 | if (Down.read() > 0.83) { |
CamJohnston | 0:68efaf4d1fa6 | 23 | RightUp.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 24 | RightDown.write(1); |
CamJohnston | 0:68efaf4d1fa6 | 25 | LeftUp.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 26 | LeftDown.write(1); |
CamJohnston | 0:68efaf4d1fa6 | 27 | } |
CamJohnston | 0:68efaf4d1fa6 | 28 | if (Right.read() > 0.83) { |
CamJohnston | 0:68efaf4d1fa6 | 29 | RightUp.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 30 | RightDown.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 31 | LeftUp.write(1); |
CamJohnston | 0:68efaf4d1fa6 | 32 | LeftDown.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 33 | } |
CamJohnston | 0:68efaf4d1fa6 | 34 | if (Left.read() > 0.83) { |
CamJohnston | 0:68efaf4d1fa6 | 35 | RightUp.write(1); |
CamJohnston | 0:68efaf4d1fa6 | 36 | RightDown.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 37 | LeftUp.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 38 | LeftDown.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 39 | } |
CamJohnston | 0:68efaf4d1fa6 | 40 | if (Left.read() < 0.83 & Right.read() < 0.83 & Down.read() < 0.83 & Up.read() < 0.83) { |
CamJohnston | 0:68efaf4d1fa6 | 41 | RightUp.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 42 | RightDown.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 43 | LeftUp.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 44 | LeftDown.write(0); |
CamJohnston | 0:68efaf4d1fa6 | 45 | } |
CamJohnston | 0:68efaf4d1fa6 | 46 | } |
CamJohnston | 0:68efaf4d1fa6 | 47 | } |