====== micro:bit Robot Control ======
Bauteile:
2x https://shop.pimoroni.de/products/microbit \\
Transmitter: https://shop.pimoroni.de/products/bit-commander-console-controller-for-micro-bit \\
Receiver: https://shop.pimoroni.de/products/robotbit-robotics-expansion-board-for-micro-bit \\
Motoren und Räder: https://shop.pimoroni.de/products/maker-essentials-micro-motors-grippy-wheels \\
Ball Caster: https://shop.pimoroni.de/products/pololu-ball-caster-with-3-4-metal-ball?variant=6984425476 \\
Chassis: 3D-Vorlage folgt...
Sender Code
let potix = 0
let potiy = 0
radio.setGroup(1)
basic.forever(function () {
let poti = 0
potiy = pins.analogReadPin(AnalogPin.P2)
potix = pins.analogReadPin(AnalogPin.P1)
radio.sendNumber(poti)
radio.sendValue("x", potix)
radio.sendValue("y", potiy)
})
Receiver
radio.onReceivedValue(function (name, value) {
if (name == "y") {
speeda = value / 2
speeda = speeda - 282
}
if (name == "x") {
turna = value / 4
turna = turna - 144
if (turna > 0) {
turna = 114 - turna
turna = turna / 114
speedl = speeda
speedr = speeda * turna
} else {
turna = turna + 147
turna = turna / 147
speedr = speeda
speedl = speeda * turna
}
}
})
let speeda = 0
let turna = 0
let speedl = 0
let speedr = 0
turna = 0
radio.setGroup(1)
basic.forever(function () {
robotbit.MotorRunDual(
robotbit.Motors.M2A,
speedl,
robotbit.Motors.M1A,
speedr
)
})