Crawford Central

Middle School Robotics Minors

GoPiGo Tasks

Make a dancing robot, the one that moves to music!

Below is the sample code using a speaker and some sample music files:

import easygopigo3 as easy
import pygame

gpg = easy.EasyGoPiGo3()

# Play music

# Add actions

# Stop playing music

Music Files

Arduino Robot Tasks:

Explore line following, obstacle avoidance programs using Elegoo robots

Middle School Robotics Majors


  • Your robot must use a speaker and play music.
  • Your code must use an if statement. Ask a teaching assistant for help with this task!
  • Your code must use a loop (such as for or while loop). Ask a teaching assistant for help with this task!

Below is the sample code using a distance sensor and a speaker:

import easygopigo3 as easy
import time
import pygame

gpg = easy.EasyGoPiGo3()
my_distance_sensor = gpg.init_distance_sensor() # init the distance sensor, the distance will be measure in millimeter
max_dis_t = 25 # maximum steps the robot can go
min_distance = 250 # the min distance to a curtain object is 250mm
t = 0  # init the number of steps

# Play music

while t <= max_dis_t:
    # Directly print the values of the sensor.
    print("Distance Sensor Reading (mm): " + str(my_distance_sensor.read_mm()))

    t = t + 1
    print("time = ", t)

    # if not encounter an object
    if my_distance_sensor.read_mm() > min_distance:
        gpg.drive_inches(5)       # go straight 5 inches
        gpg.turn_degrees(90)    # turn right if encounter a object

# Stop playing music

Reminders on Working with GoPiGo Robots

  1. Turn on battery and turn on the robot
  2. Go to
  3. Go to Code -> Python
  4. Try existing Python code
  5. Create own code for robot races
  6. Shut down the robot

Arduino Robots