Back to Spike Prime Virtual

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.

🔵 Connect ▶ Run ■ Stop Python Blocks C 🎮 Simulator ✨ AI Chat 1 from pybricks.hubs import PrimeHub 2 hub = PrimeHub() 3 hub.light.on(Color.BLUE) Code Editor AI / Terminal Disconnected Terms of Service | Privacy Policy | Contact Us | FAQ Spike Prime

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.

1 Turn on your Spike Prime hub

Press the center button on your hub. Wait for the light to appear.

2 Click the Connect button (Bluetooth icon)

In the toolbar at the top, click the blue Bluetooth button. Your browser will show a pairing dialog.

3 Select your hub from the list

Choose your hub (usually named "Pybricks Hub") and click Pair. The status bar will show "Connected".

Spike Prime Bluetooth Spike Prime Virtual 🔵 Connected ✓ Pybricks Hub
⚠ 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.

1 Select the "Python" tab in the toolbar
2 Write your Python code

The editor supports syntax highlighting, auto-complete, and error checking.

3 Click ▶ 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 import PrimeHub
from pybricks.pupdevices import Motor
from pybricks.parameters import Port, Color
from pybricks.robotics import DriveBase

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.

1 Select the "Blocks" tab in the toolbar
2 Drag blocks from the toolbox on the left

Available categories: Movement, Sensors, Sound, Light, Logic, Loops, and more.

3 Snap blocks into the "When Run" hat block

Only blocks connected to a "When Run" block will execute. Disconnected blocks are ignored.

When ▶ Run Drive forward 200 mm Turn right 90 degrees Stop all motors ✓ Connected — will run ✗ Disconnected — 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.

1 Select the "C" tab in the toolbar
2 Write your C code using the Pybricks C API
3 Build & 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.

1 Click the 🎮 Simulator button in the toolbar

A new simulator window will open with a 3D view of the robot.

2 Write code in the Python or Blocks editor
3 Click ▶ Run — code executes in the simulator

You'll see the virtual robot move, turn, and respond to your commands in real time.

Spike Prime Virtual drive_base.straight(200) drive_base.turn(90) IDE BroadcastChannel Simulator 3D Simulator

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.

Robot: Basic Claw Robot ▾ Map: Map with Cans ▾ ← Click to switch Open Claw Close Claw Wheel Grip: 30% Input: Keyboard Available Maps: Map with Cans Colored cans to grab with claw Line Follow Black line on white surface Line Intermediate Harder curves & intersections Maze Navigate walls to the exit
💡 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).

Keyboard Controls Arrow Keys Forward Left Backward Right — or — WASD Keys W A S D Special Keys SPACE → Brake / Stop O → Open Claw P → Close Claw Camera Controls Click + Drag → Rotate camera Scroll → Zoom in/out
💡 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:

Step 1: Drive toward a can W Drive forward toward the can Step 2: Close claw to grab Grabbed! P Close claw — grips the can Step 3: Carry & release O Open claw — releases the can 📝 Do it with code instead: 1 from pybricks.hubs import PrimeHub 2 from pybricks.pupdevices import Motor 3 from pybricks.parameters import Port 4 # Drive forward, close claw, reverse 5 drive_base.straight( 200 ) # approach the can 6 Motor (Port.A).run_angle( 200 , -90 ) # close claw 7 drive_base.straight( -200 ) # reverse with can
⚠ 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:

7. Saving & Loading Files

Your code is automatically saved in the browser's local storage. You can also export and import files.

💡 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

1 Click the ✨ AI button in the toolbar

The AI panel slides open on the right side of the editor.

Python Blocks C ▶ Run ✨ AI

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:

✨ AI Assistant Gemini 🤖 Spike Prime AI Assistant Ask me about Spike Prime coding! Quick prompts: 🚗 Drive forward 🎨 Line follow 🔊 Play sound AI Assistant is a premium feature. Subscribe to unlock AI-powered help. Subscribe to Unlock

Non-subscribers see a "Subscribe to Unlock" prompt at the bottom of the AI panel.

2 Click "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.

3 Enter 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:

✨ AI Assistant Gemini 👤 You Write code to drive forward 500mm 🤖 Gemini Here's the code: python Insert Copy from pybricks.hubs import PrimeHub from pybricks.pupdevices import Motor left = Motor(Port.A) right = Motor(Port.B) db = DriveBase(left, right, wheel_diameter=56, axle_track=114) db.straight(500) 📎 Editor code will be shared as context Ask about Spike Prime coding...

The AI panel with a conversation — code blocks have Insert & Copy buttons.

4 Type 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.

5 Use 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.

6 Try 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:

To remove these limits and unlock unlimited usage:

  1. Purchase an activation code via the PayPal link shown in the activation popup.
  2. Enter your activation code in the popup dialog.
  3. 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.

Q: My code runs in the simulator but not on the hub.

Q: The simulator doesn't open.

Q: My activation code doesn't work.

Still need help? Contact us and we'll be happy to assist.