The transmitter micro:bit should still be running the same script from the previous activity. That’s radio_tilt_controller_w_stop_range.
Now for the new cyber:bot receiver script!
# radio_tilt_bot_fb_lr_with_stop_range from cyberbot import * import radio radio.on() radio.config(channel=7, queue=1, length=64) while True: packet = radio.receive() if packet: dictionary = eval(packet) x = dictionary.get('x') y = dictionary.get('y') needle = dictionary.get('needle') fb = y / 10 lr = x / 10 if abs(fb) > 8: display.show(Image.ALL_CLOCKS[needle]) vL = fb vR = -fb if(fb < 0): lr = -lr vL = vL - lr vR = vR - lr else: display.show(Image.DIAMOND_SMALL) bot(18).servo_speed(vL) bot(19).servo_speed(vR)
Tilt the micro:bit transmitter | Verify the cyber:bot maneuver |
---|---|
Level | Stay still |
Slightly away from you | Forward slowly |
Further away from you | Forward faster |
Slightly toward you | Slowly backward |
Further toward you | Faster backward |
Away from you and to the left | Curve forward and to the left |
Away from you and to the right | Curve forward and to the right |
Toward you and to the left | Curve backward and to the left |
Toward you and to the right | Curve backward and to the right |