This is the script to run on the cyber:bot robot. It receives values from the micro:bit tilt controller that are used for its Feedback 360 drive servos and Gripper servo.
radio_tilt_grip_controlled_cyberbot_with_fb360.hex [1]
The .hex file download was created by entering the Python script below into the python.microbit.org/v/2 editor, and also adding the cyberbot.py and Feedback360.py modules to the Project File as shown in Add Modules to your micro:bit. [3] The Script Name was set to radio_tilt_grip_controller before saving it as a .hex file as shown in How to Save and Reopen a Script in Python Editor v2 [4].
# radio_tilt_grip_controlled_cyberbot_with_fb360 from cyberbot import * from feedback360 import * import radio drive.connect() radio.on() radio.config(channel=7, queue=1, length=64) while True: packet = radio.receive() if packet: try: dictionary = eval(packet) x = dictionary.get('x') y = dictionary.get('y') needle = dictionary.get('needle') fb = y / 10 lr = x / 10 button = dictionary['button'] # added except Exception as e: display.show(Image.SAD) print("Exception e:", e) print("Type:", type(e)) continue else: if abs(y) > 80: display.show(Image.ALL_CLOCKS[needle]) vL = fb vR = -fb if(fb < 0): lr = -lr vL = vL - lr/2 # Reduced lr term by 2 vR = vR - lr/2 # Reduced lr term by 2 else: display.show(Image.DIAMOND_SMALL) vL = 0 vR = 0 if button == 'B': # added bot(15).servo_angle(30) # added Gripper close & lift elif button == 'A': # added bot(15).servo_angle(150) # added Gripper lower & open finally: drive.speed(vL/2, -vR/2)
Links
[1] https://learn.parallax.com/sites/default/files/content/cyberbot/GripperF360/Hex/radio_tilt_grip_controlled_cyberbot_with_fb360.hex
[2] https://python.micrbit.org/v/2
[3] https://learn.parallax.com/tutorials/robot/cyberbot/add-modules-your-microbit
[4] https://learn.parallax.com/tutorials/robot/cyberbot/how-save-and-reopen-script-python-editor-v2