Follow these step-by-step instructions to test the tilt-drive and button Gripper control functions.
The scripts in this project are just slightly expanded versions of the ones from the Cybersecurity: Radio Tilt Control [1] tutorial’s Radio Tilt Controlled cyber:bot [2] activity.
To add button control to the Radio Tilt Controller Code [3], the routine below was added to the transmitter 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 [4].
button = dictionary['button'] # added
These lines were added to respond to the button values by lowering/opening or closing/lifting the Gripper paddles.
if button == 'B': # added bot(16).servo_angle(30) # added Gripper close & lift elif button == 'A': # added bot(16).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/cybersecurity-radio-tilt-control/radio-tilt-controlled-cyberbot-app/radio-0
[4] https://learn.parallax.com/tutorials/robot/cyberbot/cybersecurity-radio-tilt-control/radio-tilt-controlled-cyberbot-app/radio