Introduction
In this lesson, you’ll build Larvy - the SPIKE larva robot! It’s named that way because it moves just like a larva or caterpillar. The program behind it is quite simple, with a core made up of just three movement blocks in a loop. We’ve added a few tweaks, though, to make it run more smoothly and consistently. You can read more about how it works in the program description.
But first - let’s build the robot!
Larvy - LEGO SPIKE Prime larva robot
Larvy is a SPIKE Prime robot that moves like a larva or caterpillar. It uses a Large Motor to contract and expand its body, mimicking the crawling motion.
Using two Medium Motors, it rotates four wheels - tilting them sideways or upright as needed - so it can move forward!
A program for the robot can be found here: Program for Larvy - LEGO SPIKE Prime robot
Before you download the program, make sure you have the SPIKE programming software installed.
To get the software, download the appropriate installer for your operating system from here: https://education.lego.com/en-us/downloads/spike-prime/software
Once downloaded, simply run the installer and it will set everything up for you.
To open the program we’ve provided below, just double-click the downloaded file and it should open with the SPIKE Prime software. Alternatively, you can open the SPIKE Prime software first, go to File → Open File, and select the downloaded file manually.
Program for Larvy - LEGO SPIKE Prime robot - LSAv3.4.5.llsp3
This program makes Larvy - LEGO SPIKE Prime larva robot move forward indefinitely! The movement of this robot is very interesting as it works like a caterpillar or larvae! The program works by repeating 3 movements every cycle of the loop:
- the front motor rotates for 90 degrees, rising or collapsing its wheels
- the large motor rotates for 90 degrees, contracting or expanding the robot
- the back motor rotates for 90 degrees, rising or collapsing its wheels
You may notice that every movement command does two things, or the same thing but a different direction. That is done using a variable that is either 1 or -1, and that gives the direction that the motors should move. This variable is also used to determine which motor should use full power and which shouldn't so that the robot doesn't break itself!
How to Connect Your Computer to the SPIKE Prime Hub
After downloading the SPIKE programming software, you’ll need to connect to your hub in order to load a program to your robot. Let’s take a look at how you can do that!
There are two ways to connect your computer to your hub: using a cable or via Bluetooth.
To connect with a cable, simply plug it into both your computer and the hub. They should connect automatically! This method also charges the hub’s battery.
Bluetooth is usually the preferred option because it gives your robot the freedom to move around the room. This makes it much easier to monitor things like sensor readings or variable values while the robot is in motion. We’ve shown how to do this in the video, but here’s a quick overview of the main steps:
- Turn on the hub by pressing and holding the center button for 1–2 seconds.
- Enable Bluetooth by pressing the Bluetooth button.
- Find your hub in the SPIKE app and connect to it—watch the video for a step-by-step guide on navigating to this option.