1 ' I2C Motor Driver DRV8830 Test 2 ' A:Motor 1's DRV8830 Address , B:Motor 2's DRV8830 Address 3 ' C:Motor 1's speed, D:Motor 2's speed 4 ' S:Sensor (Analog input) value 10 clt:clv 20 A=#64:B=#63 99 goto 710 100 ' set speed.C:Mortor 1's Speed.D:Motor 2's Speed 110 if C<0 then E=1 else E=2 120 if C=0 then E=0 130 E=E+((ABS(C)-5)<<2) 140 if D<0 then F=1 else F=2 150 if D=0 then 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 250 ' stop 260 poke #700, 0, 3, 3 270 R=i2cw(A, #700, 1, #701, 1) 280 R=i2cw(B, #700, 1, #702, 1) 290 return 700 ' 710 for I=0 to 50 720 P=ANA():if P<400 goto 750 730 C=-60:D=0:gosub 110 740 wait 60 750 C=80:D=80:gosub 110 760 wait 15 770 next 780 end