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
  • AI Scripts for the cyber:bot

AI Scripts for the cyber:bot

AI cyber:bot Script

Let’s try a script that’s a little different from the overview.  It’s a little easier to manage on a table.  Here, we will make the cyber:bot roll forward for 1.25 seconds, then turn in place for 0.85 seconds.  At the time of this writing, ChatGPT has trouble with this, so we are using Bing Chat.

  • Read the chat interactions below.
    • Does it look like the script will work?
    • Did you notice the warning about needing the cyberbot module?  
    • This AI can also search the web, did the resource it supplied look helpful?

User

Write a Python script to make the cyber:bot robot roll forward for 1250 ms, then rotate right in place for 850 ms.

Bing Chat

Searching for: cyber:bot robot roll forward for 1250 ms, then rotate right in place for 850 ms

Searching for: Python script cyber:bot robot roll forward for 1250 ms, then rotate right in place for 850 ms

Generating answers for you…

Here is a Python script that makes the cyber:bot robot roll forward for 1250 ms, then rotate right in place for 850 ms:

Python
AI-generated code. Review and use carefully. More info on FAQ.

from cyberbot import *
import time

# Roll forward for 1250 ms
bot(18).servo_speed(75) # Left wheel counterclockwise
bot(19).servo_speed(-75) # Right wheel clockwise
time.sleep(1.25)

# Rotate right in place for 850 ms
bot(18).servo_speed(75) # Left wheel counterclockwise
bot(19).servo_speed(75) # Right wheel counterclockwise
time.sleep(0.85)

# Stop the servos
bot(18).servo_speed(None)
bot(19).servo_speed(None)

This script uses the cyberbot library to control the robot’s servos. The bot(18) and bot(19) calls are used to control the left and right wheels, respectively. The servo_speed function is used to set the speed and direction of each servo. The time.sleep function is used to pause the script execution for the specified duration.

I hope this helps!

Learn more:

1. learn.parallax.com

Use the AI Generated Script

  • Right-click cyberbot-template-with-blink.hex and save it to your computer. (This template is available from the tutorial Add modules to your micro:bit .)

cyberbot-template-with-blink.hex

  • Open it with the micro:bit Python Editor.
  • Replace the default template script with the script generated by the chatbot.
  • Set the script name to ai-forward-right-stop.
  • Click Save to keep a copy of your work.
  • Make sure battery pack has 5 good AA batteries and is plugged into the cyber:bot board.
  • Set the PWR switch to 0.
  • Connect the cyber:bot’s micro:bit to USB.
  • Click Send to micro:bit to load it into the cyber:bot.

Tests

  • Unplug the cyber:bot from USB, then set the PWR switch to 2.
  • If the cyber:bot doesn’t start immediately, press and release the reset button under the micro:bit next to the USB connector.
  • Test the cyber:bot robot’s navigation.  

Did the cyber:bot roll forward and turn right as expected?

Which would be quicker for tuning the right turn to 90 degrees, asking the AI to do it, or just testing and updating time.sleep values?

 


Printer-friendly version
Give Feedback on the Script
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress