Image for post
Image for post

Sphero Edu + Swift Playgrounds

Sphero Edu
Aug 21, 2017 · 6 min read

Introducing the Sphero Arcade

Swift Playgrounds — “Everyone Can Code”

Code. The universal language of technology that powers everything around us. As technology continues to evolve and play a huge part of our daily lives, programming skills are becoming more and more essential. Apple thinks everyone should have the opportunity to create something that can change the world, so they designed the Swift language, which lets anyone easily learn, write, and teach code.

At the Apple Worldwide Developers Conference in 2016, Apple announced Swift Playgrounds, a revolutionary app for the iPad that makes learning the Swift language interactive and fun for all learners. Swift Playgrounds is essentially a video game that teaches kids how to code using Apple’s Swift programming language. The interface allows you see what you’re creating with code as you write it — type your code on the left and immediately see the result on the right. Earlier in 2017, the Sphero Edu team partnered with Apple to build the first integrated Playground content designed to control real world robots. On June 5th at WWDC, Apple unveiled the new content that is now part of the Swift Playgrounds app. Thanks to our new partnership, you can now program the Sphero BOLT, Sphero SPRK+, and Sphero Mini robots in two Swift Playground books: the Sphero Arcade and the Sphero Template.

The Sphero Arcade Playground — Code classic games with Sphero

In this arcade-style playground, you can recreate classic games with a Sphero SPRK+ robot while learning the basics of game design. You’ll build your very own robotic renditions of some famous games like Pong, Bop It, and Pac-Man. Each game uses Sphero in a different way such as rolling on the floor, detecting gestures, or using Sphero as a joystick.

Image for post
Image for post

Chapter One: Get Rolling

If you’ve never used a Sphero, Swift Playgrounds is a great opportunity to dive in. Learn the basics of the robotic ball to set you up for success in building fun games. Learn to roll, aim, control the LEDs, change heading, and detect collisions. Once you master the basics, you’re off to the arcade.

Image for post
Image for post

Chapter Two: Pong

The world’s first popular video game, Pong, launched in 1972 to replicate a basic ping-pong game table. We all remember the simple white bars bouncing the ball back and forth. Our rendition of Pong gets a little more physical as it leverages Sphero as a rolling ball on the ground.

In this robotic 21st century version, your Sphero replaces the ping-pong ball, and 2 players use their feet to bounce Sphero back and forth. Users write code to detect collisions, create random bounce angles, use variables to keep track of player possession and score, and the “locator” sensor to determine when one player misses the ball and a point is awarded. The locator data is reported back from encoders on the motors in Sphero, providing the user with accurate X and Y distance measurements to use. The first player to score 3 points wins.

Image for post
Image for post

Chapter Three: Bop It

One of the most popular handheld electronic toys launched in 1996, Bop-it calls out gestures for a user to match quickly or the game ends. If you remember Bop-it, the theme is probably already playing in your head.

To recreate Bop-it, users leverage the Inertial Measurement Unit (IMU) to define and detect gestures like a tap, toss, spin, and shake in Sphero. Each gesture is defined in a function and sounds are added to round out the experience. Then, users code each function into an array and the program calls gestures randomly to create the unpredictable gameplay. As user’s progress through the game, the functions are called faster and faster. The object is to score as many points as you can.

Image for post
Image for post


One of the most recognizable games of all-time, Pac-Man was made in 1980 by Toru Iwatani, a Japanese designer that wanted to attract more women to arcade games (YES!) Users control Pac-Man as it eats dots within a maze, while avoiding ghosts to survive. There was no greater satisfaction than getting a power up and devouring the ghosts that tried to devour you…

To build Sphero Pac-Man, users leverage the gyroscope orientation angles to transform Sphero into a handheld controller to navigate through the maze, instead of the old-school arcade joystick. The roll angle (side-to-side tilt) controls the left and right movement, and pitch angle (forward-to-backward tilt) controls the up and down movement. Then users add code to track scoring points, power ups that allow them to eat ghosts, and even program smart ghosts that taunt and follow Pac-Man based on your XY coordinates on the screen.

The Sphero Template

Drive your robot and build open programs

This playground book contains two utility pages that connect Swift code to Sphero. It’s not a thematic coding journey like the Sphero Arcade. The first page is an open template that allows you to build your own free-form programs with a Sphero robot. Review the Sphero API documentation in the “glossary” for a list of commands to control your robot. The second page is an interactive joystick to drive your robot, and it allows you to modify the joystick algorithm that affects the driving behavior.

Like the Sphero Arcade, the Sphero Template playground also works with Sphero BOLT, Sphero SPRK+, and Sphero Mini. As a bonus, the template is also compatible with our Star Wars droids BB-8, R2-D2 and BB-9E.

Head to the Arcade

Get the Playgrounds

  1. Download the Swift Playgrounds app on your iPad
  2. Open the app and tap “See All” in the lower right
  3. Tap “Browse Subscriptions” at the bottom
  4. Notice the Sphero card in the Safari browser, and tap “Subscribe in Swift Playgrounds” button — Tap “Subscribe” on the prompt
  5. Notice the Sphero feed now appears in the app. Tap “Get” on the Sphero Arcade and Sphero Template playgrounds
  6. Open either playground and when on the first coding page, tap “Connect Robot” in the upper right to connect your Sphero robot over Bluetooth. Ensure your robot is charged and not in SLEEP mode so it can be discovered by the app.
Image for post
Image for post

You can’t use the playgrounds without a Sphero robot, so pick one up and get coding in Sphero Arcade. No quarters required.

Are you a teacher and need the code solutions for the Sphero Arcade? Email us at and we’ll send you a special version of the playground with the code solutions built in!

Image for post
Image for post


Schools, Parents, Robots, Kids.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store