Follow these step-by-step instructions to test the tilt-drive and Gripper control features of the remote controlled cyber:bot with Gripper and Feedback 360° servos.
The scripts in this activity are just slightly expanded versions of the ones from the Cybersecurity: Radio Tilt Control [1] tutorial’s Radio Tilt Controlled cyber:bot App [2] activity.
First, the script had to be ported from continuous rotation servo control to Feedback 360° servo control. The changes to the script that have to be made to work with the new servos are explained in the How to Update Scripts for Feedback 360° Servos [3] activity.
To add button control to the Radio Tilt Controller Code [4], the routine below was added to the transmitting tilt controller app. It expands the dictionary to contain data indicating which of the micro:bit module’s buttons were pressed. Before this, it just contained x, y, and needle key value pairs.
if button_b.was_pressed(): # add dictionary['button'] = 'B' # add elif button_a.was_pressed(): # add dictionary['button'] = 'A' # add else: dictionary['button'] = 'None' # add
This line was added to the Radio Controlled cyber:bot Code.
button = dictionary['button'] # added
These lines were added to respond to the button values by opening or closing the Gripper.
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
Links
[1] https://learn.parallax.com/tutorials/robot/cyberbot/cybersecurity-radio-tilt-control
[2] https://learn.parallax.com/tutorials/robot/cyberbot/cybersecurity-radio-tilt-control/radio-tilt-controlled-cyberbot-app
[3] https://learn.parallax.com/tutorials/robot/cyberbot/upgrade-your-cyberbot-feedback-360-servos/how-update-scripts-feedback-360-1
[4] https://learn.parallax.com/tutorials/robot/cyberbot/cybersecurity-radio-tilt-control/radio-tilt-controlled-cyberbot-app/radio-0