Created
June 13, 2015 03:19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 clt:clv:A=#64:B=#65:goto 610 | |
110 if C<0 E=1 else E=2 | |
120 if C=0 E=0 | |
130 E=E+(ABS(C)-5)<<2 | |
140 if D<0 F=1 else F=2 | |
150 if D=0 F=0 | |
160 F=F+(ABS(D)-5)<<2 | |
170 poke #700, 0, E, F | |
180 R=i2cw(A, #700, 1, #701, 1) | |
190 R=i2cw(B, #700, 1, #702, 1) | |
200 return | |
300 ' stop | |
310 C=0:D=0:gosub 110 | |
320 return | |
400 ' right punch to left | |
410 C=0:D=-50:gosub 110 | |
420 return | |
460 C=50:D=0:gosub 110 | |
470 return | |
510 C=50:D=-50:gosub 110 | |
520 return | |
600 ' main | |
610 P=ANA(0):Q=ANA(2) | |
620 ?P;",";Q | |
640 if P>=300 and Q<300 gosub 410 | |
650 if P<300 and Q>=300 gosub 460 | |
660 if P>300 and Q>=300 gosub 510 | |
670 if P<300 and Q<300 gosub 310 | |
680 goto 610 | |
1000 ' 以下コメントです。入力不要。。 | |
1001 ' タミヤのボクシングロボットをDRV8830 I2Cモータドライバと | |
1002 ' PSD測距センサで動かす。 | |
1110 ' 変数説明: | |
1120 ' A: 左モータ用DRV8830のI2Cアドレス | |
1130 ' B: 右モータ用DRV8830のI2Cアドレス | |
1140 ' C: 左モータのスピード | |
1150 ' D: 右モータのスピード | |
1160 ' P: 左PSD測距センサのアナログ値 | |
1170 ' Q: 右PSD測距センサのアナログ値 | |
2000 ' プログラムブロック説明 | |
2010 ' 10 初期化して、メイン処理へ | |
2020 ' 110~200 モータのスピード設定 | |
2040 ' 410~420 右パンチを出して、左方向へ進む | |
2050 ' 460~470 左パンチを出して、右方向へ進む | |
2060 ' 510~520 左右のパンチで前進 | |
2070 ' 600~680 メイン処理。PSD測距センサの値で動作分け。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment