Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Tilt-Controlled Gripper with the cyber:bot Robot

Tilt-Controlled Gripper with the cyber:bot Robot

Script for Tilt & Grip Controller

This is the script to run on the micro:bit module serving as the tilt controller for the Gripper-equipped cyber:bot robot.  It takes measurements from its onboard tilt sensor and sends radio data values to the cyber:bot for its drive servos and Gripper servo.

  • Right-click the radio_tilt_grip_controller.hex link below, choose Save As, and then save the file to your computer.

radio_tilt_grip_controller

  • Open the saved file with the micro:bit Python Editor editor.

The script was created by entering the text below into the python.microbit.org editor.  The Script Name was set to cyber_bot_gripper_forward_object before saving it as a .hex file as shown in Save & Edit Scripts.

Project Script: radio_tilt_grip_controller

  • Connect the micro:bit with battery pack to the USB cable.  (You can also use a second cyber:bot for this.)
  • If you changed tilt controlled cyber:bot script’s channel=7 statement, make sure to change this one to match.
  • Click Send to micro:bit.
  • Disconnect the USB from the micro:bit module.
  • Make sure the battery holder is connected to the micro:bit, and that it has some relatively new alkaline AA batteries.  Or, if you are using a cyber:bot as a tilt controller, make sure its batteries are connected and that the cyber:bot board’s PWR switch is set to 1.
# radio_tilt_grip_controller

from microbit import *
import math
import radio

radio.on()
radio.config(channel=7, queue=1, length=64)

while True:
    x = accelerometer.get_x()
    y = accelerometer.get_y()

    angle = round( math.degrees( math.atan2(y, x) ) )
    needle = ( angle + 90 + 15 ) // 30

    if abs(y) > 80:
        display.show(Image.ALL_CLOCKS[needle])
    else:
        display.show(Image.DIAMOND_SMALL)

    dictionary = { }
    dictionary['x'] = x
    dictionary['y'] = y
    dictionary['needle'] = needle
    
    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

    packet = str(dictionary)
    radio.send(packet)

    sleep(50)

 


Printer-friendly version
Script for Tilt & Grip cyber:bot
Prev
Test the Tilt-Controlled Gripper
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress