Programming with the Sphero BOLT
My first exposure with robots was at an engineering camp I attended when I was 15, and let me tell you: it was not love at first sight. I loved the programming aspect of it (that camp was also where I was introduced to programming), but I never developed a love for sticking bits of machinery together.
I avoided it so thoroughly that I managed to escape a (now mandatory) class in university that involved building robots. While my friends were playing with arduinos and drones, I was reading books about data science and the human mind.
Enter, the Sphero Bolt
When I was asked if I’d like to try out the new Sphero Bolt I was skeptical. I knew they were a robotics company and I don’t like advocating for products that I, well, don’t like. However, after unboxing it and fiddling with it for thirty minutes I was completely sold.
The Sphero Bolt is a small plastic orb with machinery inside (the guts don’t just make it move and light up, but also have a host of sensors that I haven’t even begun to explore). It differs from Sphero’s other products in that it has a matrix on top that can be used to spell out words or create shapes which provides a whole different level of interaction.
A robot for the sake of being a robot? Not cool.
A robot for the sake of education? I can get behind that.
A robot that you can program to interact with a human (or group of humans) that is also educational? Count me in.
In terms of programming, you can choose what level of complexity you’re comfortable with. They have both phone and computer apps that act as IDEs (development environments) with drag-and-drop capabilities as well as the ability to program in JavaScript. Then again, if you feel like just using the Bolt as a remote-control ball so you can run into people’s ankles, you can do that too.
Programming a Party Game in JavaScript
I don’t have a ton of room in my one-bedroom apartment, so I had no desire to set up a maze or obstacle course that I’d be tripping over for days. After looking at some of the programs published by the Sphero community, I realized that the matrix could act the interface for a video-game, but instead of buttons to push you can use the sensors to interact with it through collisions and tilts.
For my first interactive program i decided to go simple, very simple.
- I have 8 different frames (images), 7 of them are hearts in different colors, and 1 of them is a little fire symbol
- The Bolt starts out with a heart
- When it senses a collision, it randomly choose a number between 0 and 7 and displays that frame
- Rinse and Repeat
Their IDE is contained within the Sphero Edu app that you can get on either your phone or computer (or both) – it has a fair number of pre-named functions, auto-complete, and the IDE will throw errors to help you debug your code. This means that if you want to try your hand at textual programming but have never used JavaScript before you won’t get totally lost.
The IDE also allows you to do “block” programming (and it can translate the block programming into JavaScript). Block programming is akin to programming in sentences; it involves pre-made instructions you drag-and-drop into order then fill in the blanks:
“Turn 90 degrees and travel for 2 seconds” or “Show this picture on the screen”.
All this is to say that if you’re hesitant to dive right into JavaScript (or if you’re using this with a child who’s not ready for functional programming) you can create a program using the blocks and then view the JavaScript code after you’ve perfected your program.
This is what the code looks like:
[pastacode lang=”javascript” manual=”%2F%2F%20This%20is%20triggered%20as%20soon%20as%20the%20program%20starts%0Aasync%20function%20startProgram()%20%7B%0A%09playMatrixAnimation(0)%3B%0A%7D%0A%0A%2F%2F%20This%20is%20triggered%20each%20time%20there%20is%20a%20collision%0Aasync%20function%20onCollision()%20%7B%0A%09%20var%20randomNumber%20%3D%20getRandomInt(0%2C%207)%3B%0A%09%20playMatrixAnimation(randomNumber)%3B%0A%7D%0A%0AregisterEvent(EventType.onCollision%2C%20onCollision)%3B%0A%0A%2F%2F%20Each%20frame%20is%20registered%20separately%0AregisterMatrixAnimation(%7B%0A%09frames%3A%20%5B%5B%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%200%2C%200%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%201%2C%201%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%20%2F%2FHeart%0A%09%09%09%20%5D%5D%2C%0A%09fps%3A%201%2C%0A%09palette%3A%20%5B%0A%09%09%7B%20r%3A%200%2C%20g%3A%200%2C%20b%3A%200%20%7D%2C%20%0A%09%09%7B%20r%3A%20255%2C%20g%3A%200%2C%20b%3A%200%20%7D%5D%20%2F%2F%20Red%0A%7D)%3B%0A%09%0AregisterMatrixAnimation(%7B%0A%09frames%3A%20%5B%5B%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%200%2C%200%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%201%2C%201%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%20%2F%2FHeart%0A%09%09%09%20%5D%5D%2C%0A%09fps%3A%201%2C%0A%09palette%3A%20%5B%0A%09%09%7B%20r%3A%200%2C%20g%3A%200%2C%20b%3A%200%20%7D%2C%0A%09%09%7B%20r%3A%20119%2C%20g%3A%20136%2C%20b%3A%20153%20%7D%5D%20%2F%2F%20Grey%0A%7D)%3B%0A%0AregisterMatrixAnimation(%7B%0A%09frames%3A%20%5B%5B%5B0%2C%200%2C%200%2C%200%2C%202%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%202%2C%202%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%202%2C%201%2C%202%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%202%2C%201%2C%202%2C%202%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%202%2C%201%2C%201%2C%202%2C%202%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%202%2C%201%2C%201%2C%201%2C%201%2C%202%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%202%2C%202%2C%202%2C%202%2C%200%2C%200%5D%20%2F%2FFire%0A%09%09%09%20%5D%5D%2C%0A%09fps%3A%201%2C%0A%09palette%3A%20%5B%0A%09%09%7B%20r%3A%200%2C%20g%3A%200%2C%20b%3A%200%20%7D%2C%20%2F%2F%20Black%0A%09%09%7B%20r%3A%20255%2C%20g%3A%200%2C%20b%3A%200%20%7D%2C%20%2F%2F%20Red%0A%09%09%7B%20r%3A%20255%2C%20g%3A%2097%2C%20b%3A%203%20%7D%5D%20%2F%2FOrange%20%0A%7D)%3B%0A%0AregisterMatrixAnimation(%7B%0A%09frames%3A%20%5B%5B%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%200%2C%200%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%201%2C%201%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%20%2F%2FHeart%0A%09%09%09%20%5D%5D%2C%0A%09fps%3A%201%2C%0A%09palette%3A%20%5B%0A%09%09%7B%20r%3A%200%2C%20g%3A%200%2C%20b%3A%200%20%7D%2C%0A%09%09%7B%20r%3A%200%2C%20g%3A%20245%2C%20b%3A%20255%20%7D%5D%20%2F%2F%20Turquoise%0A%7D)%3B%20%0A%0AregisterMatrixAnimation(%7B%0A%09frames%3A%20%5B%5B%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%200%2C%200%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%201%2C%201%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%20%2F%2FHeart%0A%09%09%09%20%5D%5D%2C%0A%09fps%3A%201%2C%0A%09palette%3A%20%5B%0A%09%09%7B%20r%3A%200%2C%20g%3A%200%2C%20b%3A%200%20%7D%2C%0A%09%09%7B%20r%3A%20142%2C%20g%3A%2056%2C%20b%3A%20142%20%7D%5D%20%2F%2FPurple%20%0A%7D)%3B%0A%0AregisterMatrixAnimation(%7B%0A%09frames%3A%20%5B%5B%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%200%2C%200%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%201%2C%201%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%20%2F%2FHeart%0A%09%09%09%20%5D%5D%2C%0A%09fps%3A%201%2C%0A%09palette%3A%20%5B%0A%09%09%7B%20r%3A%200%2C%20g%3A%200%2C%20b%3A%200%20%7D%2C%0A%09%09%7B%20r%3A%2061%2C%20g%3A%2089%2C%20b%3A%20171%20%7D%5D%20%2F%2FCobalt%20%0A%7D)%3B%0A%0AregisterMatrixAnimation(%7B%0A%09frames%3A%20%5B%5B%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%200%2C%200%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%201%2C%201%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%20%2F%2FHeart%0A%09%09%09%20%5D%5D%2C%0A%09fps%3A%201%2C%0A%09palette%3A%20%5B%0A%09%09%7B%20r%3A%200%2C%20g%3A%200%2C%20b%3A%200%20%7D%2C%0A%09%09%7B%20r%3A%20255%2C%20g%3A%20182%2C%20b%3A%20193%20%7D%5D%20%2F%2FPink%20%0A%7D)%3B%0A%0AregisterMatrixAnimation(%7B%0A%09frames%3A%20%5B%5B%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%200%2C%200%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%5D%2C%0A%09%09%09%20%20%5B0%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%201%2C%201%2C%200%2C%200%2C%200%5D%2C%0A%09%09%09%20%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%20%2F%2FHeart%0A%09%09%09%20%5D%5D%2C%0A%09fps%3A%201%2C%0A%09palette%3A%20%5B%0A%09%09%7B%20r%3A%200%2C%20g%3A%200%2C%20b%3A%200%20%7D%2C%0A%09%09%7B%20r%3A%200%2C%20g%3A%20205%2C%20b%3A%20102%20%7D%5D%20%2F%2FCobalt%20%0A%7D)%3B” message=”Sphero Bolt Party Game” highlight=”” provider=”manual”/]
A collision is registered when the Bolt senses it’s run into something. Traditionally, this would be hitting a wall or other object, but it can also be something like being tapped or landing in someone’s hand after being thrown.
In terms of making this into a game there’s a lot of flexibility and variations you can do with this select-a-random-image pattern. Personally, I like the idea that when someone gets the fire symbol they have to answer a question or do something silly (or a different activity, depending on the age group).
This program could also be easily modified into some kind of icebreaker used by an organization by making each symbol represent a different get-to-know-you question, it could be used to decide where lunch-mates should go out to eat, or it could even be modified to create a “surprise workout routine” – if you wanted, you could get really complicated and add a timer to it. Like I said, the opportunities are endless even for adults.
To test your program you must have a bluetooth connection to load it up onto the Sphero Bolt, but it happens so fast (less than 10 seconds) that it’s easy to make minor adjustments and test as you develop.
TL;DR
Sphero sent me their new product to test out, and I absolutely love it. I can see how it would be great for teaching kids how to program, but even as an adult the applications seem pretty endless. In this blog post I explain the code for a simple game that you could use at a party or within a small group of people, but it could be modified to do pretty much anything. You can get your own here.