Mathias Riis
/
Hackathon
hej
main.cpp@0:36611331980a, 2014-04-05 (annotated)
- Committer:
- Risifutti
- Date:
- Sat Apr 05 09:30:52 2014 +0000
- Revision:
- 0:36611331980a
hej;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Risifutti | 0:36611331980a | 1 | #include "mbed.h" |
Risifutti | 0:36611331980a | 2 | #include "hack_motor.h" |
Risifutti | 0:36611331980a | 3 | |
Risifutti | 0:36611331980a | 4 | Serial pc(USBTX, USBRX); |
Risifutti | 0:36611331980a | 5 | |
Risifutti | 0:36611331980a | 6 | Wheel robot; |
Risifutti | 0:36611331980a | 7 | |
Risifutti | 0:36611331980a | 8 | main() |
Risifutti | 0:36611331980a | 9 | { |
Risifutti | 0:36611331980a | 10 | robot.init(); |
Risifutti | 0:36611331980a | 11 | char c; |
Risifutti | 0:36611331980a | 12 | pc.printf(" speed 1, 2 & 3, frem w, bagud s, venstre a & hoejre d"); |
Risifutti | 0:36611331980a | 13 | |
Risifutti | 0:36611331980a | 14 | while (1) |
Risifutti | 0:36611331980a | 15 | { |
Risifutti | 0:36611331980a | 16 | c = pc.getc(); |
Risifutti | 0:36611331980a | 17 | |
Risifutti | 0:36611331980a | 18 | switch (c) |
Risifutti | 0:36611331980a | 19 | { |
Risifutti | 0:36611331980a | 20 | case 0x31: |
Risifutti | 0:36611331980a | 21 | robot.speed = 1.0; |
Risifutti | 0:36611331980a | 22 | pc.printf("1"); |
Risifutti | 0:36611331980a | 23 | break; |
Risifutti | 0:36611331980a | 24 | |
Risifutti | 0:36611331980a | 25 | case 0x32: |
Risifutti | 0:36611331980a | 26 | robot.speed = 0.5; |
Risifutti | 0:36611331980a | 27 | pc.printf("2"); |
Risifutti | 0:36611331980a | 28 | break; |
Risifutti | 0:36611331980a | 29 | |
Risifutti | 0:36611331980a | 30 | case 0x33: |
Risifutti | 0:36611331980a | 31 | robot.speed = 0.25; |
Risifutti | 0:36611331980a | 32 | pc.printf("3"); |
Risifutti | 0:36611331980a | 33 | break; |
Risifutti | 0:36611331980a | 34 | |
Risifutti | 0:36611331980a | 35 | case 0x77: |
Risifutti | 0:36611331980a | 36 | robot.FW(); |
Risifutti | 0:36611331980a | 37 | pc.printf("w"); |
Risifutti | 0:36611331980a | 38 | break; |
Risifutti | 0:36611331980a | 39 | |
Risifutti | 0:36611331980a | 40 | case 0x73: |
Risifutti | 0:36611331980a | 41 | robot.BW(); |
Risifutti | 0:36611331980a | 42 | pc.printf("s"); |
Risifutti | 0:36611331980a | 43 | break; |
Risifutti | 0:36611331980a | 44 | |
Risifutti | 0:36611331980a | 45 | case 0x61: |
Risifutti | 0:36611331980a | 46 | robot.left(); |
Risifutti | 0:36611331980a | 47 | pc.printf("a"); |
Risifutti | 0:36611331980a | 48 | break; |
Risifutti | 0:36611331980a | 49 | |
Risifutti | 0:36611331980a | 50 | case 0x64: |
Risifutti | 0:36611331980a | 51 | robot.right(); |
Risifutti | 0:36611331980a | 52 | pc.printf("d"); |
Risifutti | 0:36611331980a | 53 | break; |
Risifutti | 0:36611331980a | 54 | |
Risifutti | 0:36611331980a | 55 | case 'n': |
Risifutti | 0:36611331980a | 56 | robot.open(); |
Risifutti | 0:36611331980a | 57 | pc.printf("n"); |
Risifutti | 0:36611331980a | 58 | break; |
Risifutti | 0:36611331980a | 59 | |
Risifutti | 0:36611331980a | 60 | case 'm': |
Risifutti | 0:36611331980a | 61 | robot.close(); |
Risifutti | 0:36611331980a | 62 | pc.printf("m"); |
Risifutti | 0:36611331980a | 63 | break; |
Risifutti | 0:36611331980a | 64 | |
Risifutti | 0:36611331980a | 65 | case 'h': |
Risifutti | 0:36611331980a | 66 | robot.hejs(); |
Risifutti | 0:36611331980a | 67 | pc.printf("h"); |
Risifutti | 0:36611331980a | 68 | break; |
Risifutti | 0:36611331980a | 69 | |
Risifutti | 0:36611331980a | 70 | case 'b': |
Risifutti | 0:36611331980a | 71 | robot.saenk(); |
Risifutti | 0:36611331980a | 72 | pc.printf("b"); |
Risifutti | 0:36611331980a | 73 | break; |
Risifutti | 0:36611331980a | 74 | |
Risifutti | 0:36611331980a | 75 | default : |
Risifutti | 0:36611331980a | 76 | robot.stop(); |
Risifutti | 0:36611331980a | 77 | break; |
Risifutti | 0:36611331980a | 78 | } |
Risifutti | 0:36611331980a | 79 | } |
Risifutti | 0:36611331980a | 80 | } |