SuGO Bot Matlab Code: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Die Seite wurde neu angelegt: „clear all close all clc b = Brick('ioType','usb'); motorPower = 40; while (true) disp('main') b.outputPower(0,Device.MotorA,motorPower) pause(0.…“) |
Keine Bearbeitungszusammenfassung |
||
Zeile 4: | Zeile 4: | ||
b = Brick('ioType','usb'); | b = Brick('ioType','usb'); | ||
motorPower = 40; | motorPower = 40; | ||
Zeile 17: | Zeile 16: | ||
b.outputStart(0,Device.MotorD) | b.outputStart(0,Device.MotorD) | ||
pause(0.0001); | pause(0.0001); | ||
layer = 0; | layer = 0; | ||
no1 = 0; | no1 = 0; | ||
no2 = 1; | no2 = 1; | ||
mode = -1; | mode = -1; | ||
ultrasonic = b.inputReadSI(layer,no1,mode); | ultrasonic = b.inputReadSI(layer,no1,mode); | ||
pause(0.0001); | pause(0.0001); | ||
coloursensor = b.inputReadSI(layer,no2,mode); | coloursensor = b.inputReadSI(layer,no2,mode); | ||
pause(0.0001); | pause(0.0001); | ||
if coloursensor <= 10 | if coloursensor <= 10 | ||
disp('schwarze linie') | disp('schwarze linie') | ||
Zeile 53: | Zeile 50: | ||
pause(0.0001); | pause(0.0001); | ||
b.outputStart(0,Device.MotorD) | b.outputStart(0,Device.MotorD) | ||
pause(0.0001); | pause(0.0001); | ||
end | end | ||
if ultrasonic <= 30 | if ultrasonic <= 30 | ||
Zeile 67: | Zeile 63: | ||
pause(0.1); | pause(0.1); | ||
end | end | ||
if coloursensor >= 11 && ultrasonic >= 31 | if coloursensor >= 11 && ultrasonic >= 31 | ||
disp('kein gegner oder schwarze linie') | disp('kein gegner oder schwarze linie') | ||
end | end | ||
end | end | ||
b.outputStop(0,Device.MotorA,0) | b.outputStop(0,Device.MotorA,0) | ||
b.outputStop(0,Device.MotorD,0) | b.outputStop(0,Device.MotorD,0) | ||
delete(b); | delete(b); |
Version vom 21. Januar 2014, 12:22 Uhr
clear all close all clc
b = Brick('ioType','usb'); motorPower = 40;
while (true)
disp('main') b.outputPower(0,Device.MotorA,motorPower) pause(0.0001); b.outputStart(0,Device.MotorA) pause(0.0001); b.outputPower(0,Device.MotorD,motorPower) pause(0.0001); b.outputStart(0,Device.MotorD) pause(0.0001); layer = 0; no1 = 0; no2 = 1; mode = -1; ultrasonic = b.inputReadSI(layer,no1,mode); pause(0.0001); coloursensor = b.inputReadSI(layer,no2,mode); pause(0.0001);
if coloursensor <= 10 disp('schwarze linie') b.outputPower(0,Device.MotorA,-60) pause(0.0001); b.outputStart(0,Device.MotorA) pause(0.0001); b.outputPower(0,Device.MotorD,-60) pause(0.0001); b.outputStart(0,Device.MotorD) pause(0.6); b.outputPower(0,Device.MotorA,60) pause(0.0001); b.outputStart(0,Device.MotorA) pause(0.0001); b.outputPower(0,Device.MotorD,-60) pause(0.0001); b.outputStart(0,Device.MotorD) pause(0.7); b.outputPower(0,Device.MotorA,motorPower) pause(0.0001); b.outputStart(0,Device.MotorA) pause(0.0001); b.outputPower(0,Device.MotorD,motorPower) pause(0.0001); b.outputStart(0,Device.MotorD) pause(0.0001); end if ultrasonic <= 30 disp('gegner gesichtet') b.outputPower(0,Device.MotorA,90) pause(0.0001); b.outputStart(0,Device.MotorA) pause(0.0001); b.outputPower(0,Device.MotorD,90) pause(0.0001); b.outputStart(0,Device.MotorD) pause(0.1); end if coloursensor >= 11 && ultrasonic >= 31 disp('kein gegner oder schwarze linie') end
end
b.outputStop(0,Device.MotorA,0) b.outputStop(0,Device.MotorD,0)
delete(b);