Learn how to use Spike Prime Virtual to program your LEGO Spike Prime hub using Python, Blocks, or C.
1. IDE Overview
Spike Prime Virtual is an all-in-one web IDE for programming LEGO Spike Prime robots. It features three editing modes, a 3D simulator, an AI assistant, and Bluetooth connectivity to your physical hub.
The main IDE layout: toolbar, code editor, side panel, and status bar.
2. Connecting Your Hub
Spike Prime Virtual uses Web Bluetooth to connect directly to your LEGO Spike Prime hub from the browser. No drivers or software installs needed.
1Turn on your Spike Prime hub
Press the center button on your hub. Wait for the light to appear.
2Click the Connect button (Bluetooth icon)
In the toolbar at the top, click the blue Bluetooth button. Your browser will show a pairing dialog.
3Select your hub from the list
Choose your hub (usually named "Pybricks Hub") and click Pair. The status bar will show "Connected".
⚠ Browser Compatibility: Web Bluetooth requires Google Chrome, Microsoft Edge, or Opera. Safari and Firefox do not support Web Bluetooth yet.
3. Using the Python Editor
The Python editor is the default coding mode. Write Pybricks MicroPython code and run it directly on your hub or in the simulator.
1Select the "Python" tab in the toolbar
2Write your Python code
The editor supports syntax highlighting, auto-complete, and error checking.
3Click ▶ Run to execute
If connected to a hub, the code runs on the physical hub. If the simulator is open, it runs in the 3D simulator.
Example code:
from pybricks.hubs importPrimeHubfrom pybricks.pupdevices importMotorfrom pybricks.parameters import Port, Color
from pybricks.robotics importDriveBase
hub = PrimeHub()
hub.light.on(Color.BLUE)
# Set up motors and drive base
left_motor = Motor(Port.A)
right_motor = Motor(Port.B)
drive_base = DriveBase(left_motor, right_motor, 56, 114)
# Drive forward 200mm then turn right 90°
drive_base.straight(200)
drive_base.turn(90)
💡 Tip: Use Ctrl+S to save your program, and Ctrl+Enter to quickly run the code.
4. Using the Blocks Editor
The Blocks editor lets you build programs visually using drag-and-drop blocks — great for beginners or quick prototyping.
1Select the "Blocks" tab in the toolbar
2Drag blocks from the toolbox on the left
Available categories: Movement, Sensors, Sound, Light, Logic, Loops, and more.
3Snap blocks into the "When Run" hat block
Only blocks connected to a "When Run" block will execute. Disconnected blocks are ignored.
⚠ Important: Only blocks snapped into a "When Run" block will be executed. Loose blocks on the workspace are ignored.
5. Using the C Editor
The C editor is for advanced users who want to write low-level firmware code in C. This mode does not support the simulator — you need a physical hub to test C programs.
1Select the "C" tab in the toolbar
2Write your C code using the Pybricks C API
3Build & flash via DFU mode
C programs must be compiled into firmware and flashed to the hub using DFU (Device Firmware Upgrade) mode. Follow the instructions in the toolbar.
⚠ Note: The C editor does not support Simulation Mode. Programs written in C require firmware flashing via DFU mode to run on the hub.
6. Using the Simulator
The 3D simulator lets you test your Python and Blocks programs without a physical hub. It simulates motors, sensors, drive base movements, and more.
1Click the 🎮 Simulator button in the toolbar
A new simulator window will open with a 3D view of the robot.
2Write code in the Python or Blocks editor
3Click ▶ Run — code executes in the simulator
You'll see the virtual robot move, turn, and respond to your commands in real time.
6a. Switching Maps
The simulator has 4 different maps to practice on. Use the Map dropdown in the simulator's HUD panel to switch between them.
💡 Tip: The "Basic Claw Robot" works best with "Map with Cans" and "Maze". The "Line Follow Robot" is optimized for the line-follow maps with color sensors.
6b. Keyboard Navigation Controls
Drive the robot manually using your keyboard. This works in keyboard input mode (the default when no hub is connected).
💡 Tip: Arrow keys and WASD both work the same way. Hold a key to keep moving — release to stop. Combine forward + left/right to steer while driving.
6c. Grabbing Cans with the Claw
The "Basic Claw Robot" has a motorized gripper that can pick up and release colored cans on the "Map with Cans". Here's how it works:
⚠ Important: The claw only works with the "Basic Claw Robot" robot type. Make sure to select it from the Robot dropdown. The claw must be close enough to the can to grab it — drive right up to it first!
Summary of all simulator controls:
W / ↑ — Drive forward
S / ↓ — Drive backward
A / ← — Steer left
D / → — Steer right
Space — Brake / stop immediately
O — Open claw
P — Close claw
Mouse drag — Rotate camera
Scroll wheel — Zoom in/out
7. Saving & Loading Files
Your code is automatically saved in the browser's local storage. You can also export and import files.
Save/Download: Click the Download icon in the toolbar to save your program as a .py, .xml, or .c file.
Open/Import: Click the Upload icon to load a program file from your computer.
New File: Click the New File icon to start a fresh program.
💡 Tip: The Python, Blocks, and C editors each maintain their own code independently. Switching tabs doesn't overwrite your work.
8. AI Assistant
The built-in AI assistant can help you write code, explain concepts, debug errors, and learn Pybricks APIs. This is a premium feature — you need an active subscription to use it.
8a. Opening the AI Panel
1Click the ✨ AI button in the toolbar
The AI panel slides open on the right side of the editor.
8b. Subscription Required
If you haven't subscribed yet, you'll see a prompt at the bottom of the AI panel asking you to subscribe:
Non-subscribers see a "Subscribe to Unlock" prompt at the bottom of the AI panel.
2Click "Subscribe to Unlock"
This opens the activation popup where you can choose a plan (1 month, 6 months, or 12 months) and subscribe via PayPal.
3Enter your activation code
After payment, you'll receive an activation code by email. Enter it in the popup to unlock AI (and unlimited editor usage).
8c. Using the AI Assistant
Once subscribed, the input area becomes active:
The AI panel with a conversation — code blocks have Insert & Copy buttons.
4Type your question and press Enter
The AI sees your current editor code as context. Ask it to write code, explain concepts, debug errors, or suggest improvements.
5Use Insert or Copy on code blocks
Click Insert to replace your editor content with the AI's suggestion. Click Copy to copy it to your clipboard.
6Try quick prompts
When the chat is empty, quick prompt buttons are shown: Drive forward, Line follow, Play sound, Turn 90°, Display text, Read sensor, Explain code, and Fix errors.
💡 Tip: The AI automatically receives your current code as context, so you can ask "What does this code do?" or "Fix the error on line 5" without pasting anything.
9. Activation & Limits
Spike Prime Virtual offers a free tier with some limits:
Python / C: Free up to 30 lines of code per program
Blocks: Free up to 30 blocks per program
To remove these limits and unlock unlimited usage:
Purchase an activation code via the PayPal link shown in the activation popup.
Enter your activation code in the popup dialog.
Once activated, there are no limits on code length or block count.
💡 Tip: Your activation status is saved in your browser. You only need to activate once per browser.
10. Troubleshooting
Q: I can't connect to my hub.
Make sure you're using Chrome, Edge, or Opera (Web Bluetooth required).
Ensure the hub is turned on and Bluetooth is enabled on your computer.
Try turning the hub off and on again, then reconnect.
Check that the hub has Pybricks firmware installed.
Q: My code runs in the simulator but not on the hub.
Some simulator-specific blocks/functions don't translate directly. Use the Pybricks API for hub programs.
Make sure you're connected to the hub before clicking Run.
Q: The simulator doesn't open.
Make sure pop-ups are allowed for this site.
Try clicking the Simulator button again — it opens in a new window.
Q: My activation code doesn't work.
Make sure you entered the code exactly as received (it's case-insensitive).
Contact us at Contact Us if you continue having issues.
Still need help? Contact us and we'll be happy to assist.