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@2:2580959cb1f9, 2018-12-11 (annotated)
- Committer:
- hswell3221
- Date:
- Tue Dec 11 10:14:02 2018 +0000
- Revision:
- 2:2580959cb1f9
- Parent:
- 1:06b0309330c5
kiban test
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| hswell3221 | 0:6fe0fbc55b6f | 1 | #include "mbed.h" |
| hswell3221 | 0:6fe0fbc55b6f | 2 | |
| hswell3221 | 2:2580959cb1f9 | 3 | /* |
| hswell3221 | 2:2580959cb1f9 | 4 | DigitalOut stby(p23);//23 18 |
| hswell3221 | 2:2580959cb1f9 | 5 | DigitalOut Aout(p24);//22 17 |
| hswell3221 | 2:2580959cb1f9 | 6 | DigitalOut Bout(p22);//24 19 |
| hswell3221 | 2:2580959cb1f9 | 7 | DigitalOut Aout2(p26); |
| hswell3221 | 2:2580959cb1f9 | 8 | DigitalOut Bout2(p27); |
| hswell3221 | 2:2580959cb1f9 | 9 | PwmOut motorA(p25);//21 21 |
| hswell3221 | 2:2580959cb1f9 | 10 | PwmOut motorB(p21);//25 22 |
| hswell3221 | 2:2580959cb1f9 | 11 | *\ |
| hswell3221 | 2:2580959cb1f9 | 12 | |
| hswell3221 | 2:2580959cb1f9 | 13 | /*富田 |
| hswell3221 | 2:2580959cb1f9 | 14 | DigitalOut stby(p23); |
| hswell3221 | 2:2580959cb1f9 | 15 | DigitalOut Aout(p24); |
| hswell3221 | 2:2580959cb1f9 | 16 | DigitalOut Bout(p22); |
| hswell3221 | 2:2580959cb1f9 | 17 | DigitalOut Aout2(p26); |
| hswell3221 | 2:2580959cb1f9 | 18 | DigitalOut Bout2(p27); |
| hswell3221 | 2:2580959cb1f9 | 19 | PwmOut motorA(p25); |
| hswell3221 | 2:2580959cb1f9 | 20 | PwmOut motorB(p21); |
| hswell3221 | 2:2580959cb1f9 | 21 | 宮崎 |
| hswell3221 | 2:2580959cb1f9 | 22 | DigitalOut stby(p23); |
| hswell3221 | 2:2580959cb1f9 | 23 | DigitalOut Aout(p24); |
| hswell3221 | 2:2580959cb1f9 | 24 | DigitalOut Bout(p22); |
| hswell3221 | 2:2580959cb1f9 | 25 | DigitalOut Aout2(p28); |
| hswell3221 | 2:2580959cb1f9 | 26 | DigitalOut Bout2(p29); |
| hswell3221 | 2:2580959cb1f9 | 27 | PwmOut motorA(p26); |
| hswell3221 | 2:2580959cb1f9 | 28 | PwmOut motorB(p21); |
| hswell3221 | 2:2580959cb1f9 | 29 | 中西 |
| hswell3221 | 2:2580959cb1f9 | 30 | DigitalOut stby(p23); |
| hswell3221 | 2:2580959cb1f9 | 31 | DigitalOut Aout(p24); |
| hswell3221 | 2:2580959cb1f9 | 32 | DigitalOut Bout(p22); |
| hswell3221 | 2:2580959cb1f9 | 33 | DigitalOut Aout2(p30); |
| hswell3221 | 2:2580959cb1f9 | 34 | DigitalOut Bout2(p29); |
| hswell3221 | 2:2580959cb1f9 | 35 | PwmOut motorA(p25); |
| hswell3221 | 2:2580959cb1f9 | 36 | PwmOut motorB(p21); |
| hswell3221 | 2:2580959cb1f9 | 37 | */ |
| hswell3221 | 2:2580959cb1f9 | 38 | |
| hswell3221 | 2:2580959cb1f9 | 39 | Serial xbee(p9,p10); |
| hswell3221 | 0:6fe0fbc55b6f | 40 | Serial pc(USBTX,USBRX); |
| hswell3221 | 0:6fe0fbc55b6f | 41 | DigitalOut stby(p23); |
| hswell3221 | 2:2580959cb1f9 | 42 | DigitalOut Aout(p24); |
| hswell3221 | 2:2580959cb1f9 | 43 | DigitalOut Bout(p22); |
| hswell3221 | 2:2580959cb1f9 | 44 | DigitalOut Aout2(p30); |
| hswell3221 | 2:2580959cb1f9 | 45 | DigitalOut Bout2(p29); |
| hswell3221 | 2:2580959cb1f9 | 46 | PwmOut motorA(p25); |
| hswell3221 | 2:2580959cb1f9 | 47 | PwmOut motorB(p21); |
| hswell3221 | 2:2580959cb1f9 | 48 | |
| hswell3221 | 2:2580959cb1f9 | 49 | DigitalOut led1(LED1); |
| hswell3221 | 2:2580959cb1f9 | 50 | DigitalOut led2(LED2); |
| hswell3221 | 2:2580959cb1f9 | 51 | DigitalOut led3(LED3); |
| hswell3221 | 2:2580959cb1f9 | 52 | DigitalOut led4(LED4); |
| hswell3221 | 0:6fe0fbc55b6f | 53 | |
| hswell3221 | 0:6fe0fbc55b6f | 54 | int main() |
| hswell3221 | 0:6fe0fbc55b6f | 55 | { |
| hswell3221 | 0:6fe0fbc55b6f | 56 | char data; |
| hswell3221 | 0:6fe0fbc55b6f | 57 | |
| hswell3221 | 2:2580959cb1f9 | 58 | stby = 1; Aout = 1; Bout = 1; Aout2 = 0; Bout2 = 0; |
| hswell3221 | 2:2580959cb1f9 | 59 | motorA.period(0.0005); |
| hswell3221 | 2:2580959cb1f9 | 60 | motorB.period(0.0005); |
| hswell3221 | 2:2580959cb1f9 | 61 | motorA.pulsewidth(0.0005); |
| hswell3221 | 2:2580959cb1f9 | 62 | motorB.pulsewidth(0.0005); |
| hswell3221 | 2:2580959cb1f9 | 63 | led1 = 1; led2 = 0; led3 = 0; led4 = 0; |
| hswell3221 | 2:2580959cb1f9 | 64 | wait(2); |
| hswell3221 | 2:2580959cb1f9 | 65 | |
| hswell3221 | 2:2580959cb1f9 | 66 | motorA.pulsewidth(0.00025); |
| hswell3221 | 2:2580959cb1f9 | 67 | motorB.pulsewidth(0.00025); |
| hswell3221 | 2:2580959cb1f9 | 68 | led1 = 0; led2 = 1; led3 = 0; led4 = 0; |
| hswell3221 | 2:2580959cb1f9 | 69 | wait(2); |
| hswell3221 | 2:2580959cb1f9 | 70 | |
| hswell3221 | 2:2580959cb1f9 | 71 | motorA.pulsewidth(0.00); |
| hswell3221 | 2:2580959cb1f9 | 72 | motorB.pulsewidth(0.00); |
| hswell3221 | 2:2580959cb1f9 | 73 | led1 = 0; led2 = 0; led3 = 0; led4 = 0; |
| hswell3221 | 0:6fe0fbc55b6f | 74 | |
| hswell3221 | 0:6fe0fbc55b6f | 75 | pc.printf("start\n"); |
| hswell3221 | 0:6fe0fbc55b6f | 76 | |
| hswell3221 | 0:6fe0fbc55b6f | 77 | while(1) |
| hswell3221 | 0:6fe0fbc55b6f | 78 | { |
| hswell3221 | 1:06b0309330c5 | 79 | if(xbee.readable()) |
| hswell3221 | 0:6fe0fbc55b6f | 80 | { |
| hswell3221 | 0:6fe0fbc55b6f | 81 | data = xbee.getc(); |
| hswell3221 | 0:6fe0fbc55b6f | 82 | } |
| hswell3221 | 0:6fe0fbc55b6f | 83 | |
| hswell3221 | 1:06b0309330c5 | 84 | /*if(data == 'F') |
| hswell3221 | 0:6fe0fbc55b6f | 85 | { |
| hswell3221 | 2:2580959cb1f9 | 86 | motorA.pulsewidth(0.015); |
| hswell3221 | 2:2580959cb1f9 | 87 | motorB.pulsewidth(0.015); |
| hswell3221 | 1:06b0309330c5 | 88 | pc.printf("F:%c",data); |
| hswell3221 | 1:06b0309330c5 | 89 | }*/ |
| hswell3221 | 1:06b0309330c5 | 90 | |
| hswell3221 | 1:06b0309330c5 | 91 | if(data == 'A') |
| hswell3221 | 1:06b0309330c5 | 92 | { |
| hswell3221 | 2:2580959cb1f9 | 93 | led1 = 1; led2 = 0; led3 = 0; led4 = 0; |
| hswell3221 | 2:2580959cb1f9 | 94 | Aout = 1; Bout = 1; Aout2 = 0; Bout2 = 0; |
| hswell3221 | 2:2580959cb1f9 | 95 | motorA.pulsewidth(0.020); |
| hswell3221 | 2:2580959cb1f9 | 96 | motorB.pulsewidth(0.020); |
| hswell3221 | 1:06b0309330c5 | 97 | pc.printf("A:%c",data); |
| hswell3221 | 0:6fe0fbc55b6f | 98 | } |
| hswell3221 | 0:6fe0fbc55b6f | 99 | |
| hswell3221 | 2:2580959cb1f9 | 100 | else if(data == 'R') |
| hswell3221 | 0:6fe0fbc55b6f | 101 | { |
| hswell3221 | 2:2580959cb1f9 | 102 | led1 = 0; led2 = 1; led3 = 0; led4 = 0; |
| hswell3221 | 2:2580959cb1f9 | 103 | Aout = 1; Bout = 1; Aout2 = 0; Bout2 = 0; |
| hswell3221 | 2:2580959cb1f9 | 104 | motorA.pulsewidth(0.020); |
| hswell3221 | 2:2580959cb1f9 | 105 | motorB.pulsewidth(0.00); |
| hswell3221 | 0:6fe0fbc55b6f | 106 | pc.printf("R:%c",data); |
| hswell3221 | 0:6fe0fbc55b6f | 107 | } |
| hswell3221 | 0:6fe0fbc55b6f | 108 | |
| hswell3221 | 2:2580959cb1f9 | 109 | else if(data == 'L') |
| hswell3221 | 0:6fe0fbc55b6f | 110 | { |
| hswell3221 | 2:2580959cb1f9 | 111 | led1 = 0; led2 = 0; led3 = 1; led4 = 0; |
| hswell3221 | 2:2580959cb1f9 | 112 | Aout = 1; Bout = 1; Aout2 = 0; Bout2 = 0; |
| hswell3221 | 2:2580959cb1f9 | 113 | motorA.pulsewidth(0.00); |
| hswell3221 | 2:2580959cb1f9 | 114 | motorB.pulsewidth(0.020); |
| hswell3221 | 0:6fe0fbc55b6f | 115 | pc.printf("L:%c",data); |
| hswell3221 | 0:6fe0fbc55b6f | 116 | } |
| hswell3221 | 0:6fe0fbc55b6f | 117 | |
| hswell3221 | 2:2580959cb1f9 | 118 | else if(data == 'B') |
| hswell3221 | 2:2580959cb1f9 | 119 | { |
| hswell3221 | 2:2580959cb1f9 | 120 | led1 = 0; led2 = 0; led3 = 0; led4 = 1; |
| hswell3221 | 2:2580959cb1f9 | 121 | Aout = 0; Bout = 0; Aout2 = 1; Bout2 = 1; |
| hswell3221 | 2:2580959cb1f9 | 122 | motorA.pulsewidth(0.015); |
| hswell3221 | 2:2580959cb1f9 | 123 | motorB.pulsewidth(0.015); |
| hswell3221 | 2:2580959cb1f9 | 124 | pc.printf("B:%c",data); |
| hswell3221 | 2:2580959cb1f9 | 125 | } |
| hswell3221 | 2:2580959cb1f9 | 126 | |
| hswell3221 | 2:2580959cb1f9 | 127 | else if(data == 'N') |
| hswell3221 | 2:2580959cb1f9 | 128 | { |
| hswell3221 | 2:2580959cb1f9 | 129 | led1 = 0; led2 = 0; led3 = 0; led4 = 0; |
| hswell3221 | 2:2580959cb1f9 | 130 | Aout = 1; Bout = 1; Aout2 = 0; Bout2 = 0; |
| hswell3221 | 2:2580959cb1f9 | 131 | motorA.pulsewidth(0.000); |
| hswell3221 | 2:2580959cb1f9 | 132 | motorB.pulsewidth(0.000); |
| hswell3221 | 0:6fe0fbc55b6f | 133 | pc.printf("N:%c",data); |
| hswell3221 | 0:6fe0fbc55b6f | 134 | } |
| hswell3221 | 0:6fe0fbc55b6f | 135 | |
| hswell3221 | 1:06b0309330c5 | 136 | //data = 'N'; |
| hswell3221 | 0:6fe0fbc55b6f | 137 | |
| hswell3221 | 0:6fe0fbc55b6f | 138 | } |
| hswell3221 | 0:6fe0fbc55b6f | 139 | } |