Lesson 02 The Night Shift · Scratch

Scratch Tutorials

Blocks · drag, drop and drive

Learn to program LEGO robots using colorful drag-and-drop blocks. Perfect for beginners and young builders!

Example: Move forward when button pressed

  1. When program starts
  2. forever
  3. if <button pressed> then
  4. move forward for 1 second

What is Scratch-Based Programming?

Scratch-based programming uses colorful blocks that snap together like LEGO bricks. Instead of typing code, you drag blocks from a palette and connect them to create programs. It's the perfect introduction to programming concepts!

Benefits

  • No typing or syntax errors
  • Visual feedback shows program flow
  • Easy to experiment and iterate
  • Great for ages 7 and up

Understanding Block Types

  • Events (Yellow)

    Start your program when something happens

    1. when program starts
    2. when button pressed
    3. when color = red
  • Motors (Blue)

    Control motor movement and speed

    1. move forward
    2. turn left 90°
    3. stop motors
  • Control (Orange)

    Control program flow and timing

    1. wait 1 second
    2. repeat 10 times
    3. forever
  • Sensing (Cyan)

    Read sensor values and detect events

    1. color sensor
    2. distance sensor
    3. tilt sensor
  • Conditions (Purple)

    Make decisions based on conditions

    1. if <condition> then
    2. if/else
    3. wait until
  • Sounds (Purple)

    Play sounds and music

    1. play sound
    2. play note
    3. set volume

Beginner Projects

  • PROJECT 1

    My First Robot Movement

    What You'll Learn

    • Starting a program with events
    • Basic motor movements
    • Using timing blocks
    • Stopping motors

    Program:

    1. when program starts
    2. move forward for 2 seconds
    3. wait 1 second
    4. turn right 90°
    5. move forward for 2 seconds
  • PROJECT 2

    Color Detector

    What You'll Learn

    • Reading color sensor values
    • Using if/then conditions
    • Playing different sounds
    • Forever loops

    Program:

    1. when program starts
    2. forever
    3. if <color = red> then
    4. play "fire truck"
    5. if <color = blue> then
    6. play "water drop"
  • PROJECT 3

    Obstacle Avoider

    What You'll Learn

    • Using distance sensors
    • Comparing values
    • Autonomous robot behavior
    • Backing up and turning

    Program:

    1. when program starts
    2. forever
    3. if <distance < 20cm>
    4. move backward 1 sec
    5. turn right 90°
    6. else
    7. move forward

LEGO Platforms with Scratch

Learn More About Scratch

Ready for Text Coding?

Once you've mastered Scratch blocks, you can graduate to Python programming!

Start Your Coding Adventure!

LEGO Boost is the perfect first step into robotics and programming

Explore LEGO Boost