The Night Shift Programming and robotics, after dark

LEGO Programming Guides

Python, Scratch and JavaScript for LEGO hubs

Build. Code. Create. Master robotics programming with LEGO's smart hubs, sensors, and motors.

Drive a Square
from pybricks.pupdevices import Motor
from pybricks.parameters import Port, Direction
from pybricks.robotics import DriveBase

left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
right_motor = Motor(Port.B)
robot = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=112)

# Four sides, four quarter turns
for side in range(4):
    robot.straight(300)
    robot.turn(90)
Line 12 · Step 8 of 8 · Heading 0° 1 square = 50 mm

Choose Your Platform

Each platform offers unique features for different skill levels

  • Advanced

    MINDSTORMS

    Robot Inventor

    Robot Inventor

    #51515 · 949 pieces

    Advanced robotics with Python and Scratch programming

    • MicroPython support
    • 6-axis gyro sensor
    • 4 motors included

    Explore MINDSTORMS

  • Educational

    SPIKE Prime

    Educational Edition

    SPIKE Prime

    #45678 · 532 pieces

    Educational robotics for classrooms and competitions

    • LEGO Education unit plans
    • FIRST LEGO League through 2027-28
    • Word Blocks and Python

    Explore SPIKE Prime

  • Creative

    LEGO Boost

    Creative Toolbox

    Creative Toolbox

    #17101 · 847 pieces

    Creative coding for younger builders

    • 5 different models
    • Visual block coding
    • Ages 7+

    Explore Boost

  • Smart Control

    Powered UP

    Smart Control

    Technic Large Hub

    #88016 · Smart Hub

    Smart hubs for trains, Technic, and custom builds

    • Train control
    • Technic integration
    • App control

    Explore Powered UP

Tonight's Lessons

  1. 01 Getting started Robotics · a first robot in three steps
  2. 02 Scratch Blocks · drag, drop and drive
  3. 03 BOOST Blocks · the Creative Toolbox's models
  4. 04 Powered Up Hubs, motors and the apps that drive them
  5. 05 MINDSTORMS Python and Scratch on the Robot Inventor hub
  6. 06 SPIKE Prime Word Blocks, Python and FIRST LEGO League
  7. 07 SPIKE Prime in class Curriculum, classrooms and competition
  8. 08 Python Pybricks · programs to copy, run and change
  9. 09 Web Bluetooth JavaScript · drive a hub from the browser
  10. 10 The bench Web Bluetooth · a live control panel

Quick Start Guide

Get up and running in three steps

  1. Choose Platform

    MINDSTORMS, SPIKE, Boost, or Powered UP

  2. Get Software

    Official LEGO app or Web Bluetooth

  3. Start Coding

    Scratch blocks or Python text

Programming Languages

Choose the right language for your skill level

  • Visual Blocks

    Scratch

    Visual programming for beginners. Ages 7+

    • Drag-and-drop interface
    • No syntax to learn
    • Instant feedback

    Tutorials

  • MicroPython

    Python

    Professional programming. Ages 12+

    • Real coding skills
    • MicroPython support
    • Advanced algorithms

    Examples

  • Web Bluetooth

    JavaScript

    Browser-based control. Advanced users

    • No app needed
    • Custom interfaces
    • Direct BLE access

    Guide

Get inspired by these robotics projects

  • Line Following Robot

    Build a robot that follows a black line using color sensors

    • MINDSTORMS
    • Python
    • Intermediate
  • Remote Control Car

    Control your LEGO car from a web browser

    • Powered UP
    • JavaScript
    • Beginner
  • Sorting Machine

    Sort LEGO bricks by color automatically

    • SPIKE Prime
    • Scratch
    • Intermediate
  • Drawing Robot

    Program a robot to draw patterns and shapes

    • Boost
    • Scratch
    • Beginner

Resources

Ready to Start Programming?

Try our interactive demo to control LEGO hubs from your browser

Launch Interactive Demo