Skip to content
Snippets Groups Projects
Commit aceec427 authored by ft-Demo's avatar ft-Demo
Browse files

commit by robo pro coding

parents
No related branches found
No related tags found
No related merge requests found
{"uuid":"b8ca70c4-ff39-4ac6-b1a5-a01967159a59","name":"BTSmart_Ball_game_2_Rebuild_Umbau","mode":"ADVANCED","version":"1.0","controller":"BT_SMART"}
\ No newline at end of file
This diff is collapsed.
var wait_time, time, speed, direction;
function mathRandomInt(a, b) {
if (a > b) {
// Swap a and b to ensure a is smaller.
var c = a;
a = b;
b = c;
}
return Math.floor(Math.random() * (b - a + 1) + a);
}
await TXT_M2_motor.setSpeed(200, Motor.CW);
await TXT_M1_motor.setSpeed(200, Motor.CCW);
await Utility.sleep(400);
await TXT_M1_motor.setSpeed(150, Motor.CW);
while(true) {
if(await TXT_I1_mini_switch.isClosed()){
break;
}
await Utility.sleep(10);
}
wait_time = 0;
time = Math.floor(Date.now() / 1000);
while(true) {
if (await TXT_I2_mini_switch.isClosed()) {
while(true) {
if(await TXT_I2_mini_switch.isOpen()){
break;
}
await Utility.sleep(10);
}
await TXT_M1_motor.setSpeed(512, Motor.CCW);
while(true) {
if(await TXT_I1_mini_switch.isOpen()){
break;
}
await Utility.sleep(10);
}
while(true) {
if(await TXT_I1_mini_switch.isClosed()){
break;
}
await Utility.sleep(10);
}
await TXT_M1_motor.stop();
await TXT_M1_motor.setSpeed(200, Motor.CW);
await Utility.sleep(100);
await TXT_M1_motor.stop();
}
if (Math.floor(Date.now() / 1000) > time + wait_time) {
time = Math.floor(Date.now() / 1000);
wait_time = mathRandomInt(1, 10);
speed = mathRandomInt(150, 300);
direction = mathRandomInt(0, 1);
if (direction == 0) {
window.alert(Math.floor(Date.now() / 1000));
window.alert(time);
window.alert('Direction 0');
await TXT_M2_motor.setSpeed(speed, Motor.CW);
} else {
await TXT_M2_motor.setSpeed(speed, Motor.CCW);
window.alert(Math.floor(Date.now() / 1000));
window.alert(time);
window.alert('Direction 1');
}
}
await Utility.sleep(10);
}
<xml xmlns="https://developers.google.com/blockly/xml" version="16"><block type="bt_smart_controller" id="tDD:E^!|r=46e@mB#|H!" x="68" y="25"><mutation><arg type="Input" name="Input-0" value="I1"/><arg type="Input" name="Input-1" value="I2"/><arg type="Input" name="Input-2" value="-"/><arg type="Motor" name="Motor-0" value="M1"/><arg type="Motor" name="Motor-1" value="M2"/></mutation><field name="controller_name">TXT</field><field name="Input-0">I1</field><field name="Input-1">I2</field><field name="Input-2">-</field><field name="Motor-0">M1</field><field name="Motor-1">M2</field><value name="Input-0"><block type="mini_switch" id="s1c/P%~/TvkL2_so1.#a"/></value><value name="Input-1"><block type="mini_switch" id="SdRJmYelf8GaCV{{xMu0"/></value><value name="Motor-0"><block type="motor" id="HiKJYKQqJul?e@$)qvv1"/></value><value name="Motor-1"><block type="motor" id="bEgxOk,:$eWW2sK_Bh(H"/></value></block></xml>
\ No newline at end of file
var TXT_I1_mini_switch = new MiniSwitch(1);
await TXT_I1_mini_switch.init();
var TXT_I2_mini_switch = new MiniSwitch(2);
await TXT_I2_mini_switch.init();
var TXT_M1_motor = new Motor(1);
await TXT_M1_motor.init();
var TXT_M2_motor = new Motor(2);
await TXT_M2_motor.init();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment