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

Give Feedback on the Script

Now that we know Bing Chat can make a script for the cyber:bot to roll forward and turn, let’s see if it can expand upon that.

  • Read the chat interactions.
    • Does it look like the modified script will work?
    • Is this really the best way to write this script?

User

Assuming this results in forward followed by a 90 degree turn, modify the script to make the cyber:bot travel in a square.

Searching for: cyber:bot travel in a square

 

AI Chatbot

Searching for: Python script cyber:bot travel in a square

Generating answers for you…

To make the cyber:bot travel in a square, you can modify the previous script to include four movements: forward, right turn, forward, and right turn. Here is the modified Python script:

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)

# 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)

# 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)

# 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)

# 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

 

Try the Expanded Script

For more information on how to write scripts to make the cyber:bot navigate, see Navigation with the cyber:bot.

  • Read the chat interactions.
    • Does it look like the modified script will work?
    • Is this really the best way to write this script?
  • Change the script name to ai-forward-right-stop-x4
  • Click Save to keep a copy of your work.
  • Replace the script with the expanded version shown above.
  • Connect your cyber:bot to USB.
  • 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.
  • Unplug the cyber:bot from USB, then set the PWR switch to 2.
  • Test the cyber:bot robot’s navigation.  
  • After tuning, can it make the cyber:bot travel in a square?

Printer-friendly version
AI cyber:bot Script
Prev
Request Efficient Code
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress