Control
Control
Imagine a robot with no instructions for when to stop, wait, or repeat.
It would be complete chaos!
That's where Control blocks come in.
Control blocks help your program:
- Wait before doing something
- Repeat actions
- Make decisions
- Count through numbers
- Stop when needed
Think of Control blocks as the traffic lights of your program. They keep everything moving in the right order.
What Are Control Blocks?
Control blocks tell your program:
WHEN to do something
HOW OFTEN to do it
HOW LONG to wait
WHEN to stop
Without Control blocks, your program would simply run from top to bottom once and then end.
Think of Control blocks as the manager of your program.
Control Category
[INSERT CATEGORY IMAGE HERE: Control]
Figure 5.1 – Blocks available in the Control category.
The Control category can be organized into four simple ideas:
WAIT
↓
DECIDE
↓
REPEAT
↓
STOP
Control Block Reference
| Block | What It Does | When To Use It |
|---|---|---|
| Delay | Pauses the program | Wait before the next action |
| If | Makes a decision | Run code only when a condition is true |
| Repeat Times | Repeats a fixed number of times | Blink an LED 10 times |
| Repeat While | Repeats while a condition remains true | Keep checking a sensor |
| For Each Range | Counts through numbers | Count from 0 to 10 |
| For Each Item | Goes through list items | Process a list one item at a time |
| Break | Stops a loop early | Exit a loop immediately |
| Pass | Does nothing | Placeholder block |
| Running Time | Tracks program time | Build timers and clocks |
| Time Difference | Calculates elapsed time | Measure how long something takes |
| Timer Setup | Creates a timer | Scheduled events |
| Timer Action | Perform an action after a period | Automatic actions |
| Reset | Restart the board | Start over |
| WDT | Watchdog timer (advanced) | System protection |
| Memory Tools | Memory management (advanced) | Advanced projects |
Delay
[INSERT BLOCK IMAGE HERE: Delay]
Sometimes your program needs to wait.
The Delay block pauses the program before moving to the next instruction.
Example
LED ON
↓
Wait 1 Second
↓
LED OFF
Real-Life Example
Think about a traffic light:
Green
↓
Wait
↓
Yellow
↓
Wait
↓
Red
Without the delay, all lights would change instantly.
Tip
Delay means "Pause here before continuing."
Making Decisions with IF
[INSERT BLOCK IMAGE HERE: IF]
The IF block lets your program make decisions.
If the condition is true, the code runs.
If the condition is false, it does not.
Example
IF Button Pressed
↓
Turn LED ON
Concept
Question
↓
TRUE?
↙ ↘
YES NO
↓ ↓
Action Skip
Real-Life Example
IF it is raining
↓
Take an umbrella
IF blocks help programs make smart choices.
Repeat a Specific Number of Times
[INSERT BLOCK IMAGE HERE: Repeat Times]
Sometimes you know exactly how many times something should happen.
Example
Repeat 10 Times
↓
Blink LED
Concept
Repeat
↓
Count
↓
Stop
Tip
Use Repeat Times when you already know the number of repetitions.
Repeat While
[INSERT BLOCK IMAGE HERE: Repeat While]
This loop keeps running while a condition remains true.
Example
While Button Not Pressed
↓
Keep Flashing LED
Concept
Condition TRUE?
↓
Keep Repeating
Real-Life Example
While the game is running
↓
Keep updating the score
Repeat While means "Keep going until something changes."
Counting Through Numbers
[INSERT BLOCK IMAGE HERE: For Each Range]
This block automatically counts through a range of numbers.
Example
0 → 5
Produces:
0
1
2
3
4
5
Concept
Start
↓
Count
↓
End
Beginner Uses
Counting scores
LED animations
Number displays
Timers
Working Through a List
[INSERT BLOCK IMAGE HERE: For Each Item]
This block processes items one at a time.
Example
List:
Apple
Banana
Orange
The loop processes:
Apple
↓
Banana
↓
Orange
Concept
Item
↓
Next Item
↓
Next Item
Stopping a Loop Early
[INSERT BLOCK IMAGE HERE: Break]
Sometimes you don't want to finish the entire loop.
The Break block immediately stops it.
Example
Repeat Forever
↓
Button Pressed
↓
Break
Concept
Loop Running
↓
Condition Met
↓
STOP LOOP
Break = Exit the loop now.
Pass
[INSERT BLOCK IMAGE HERE: Pass]
Pass does nothing.
Really!
It simply allows the program to continue.
Example
IF condition
↓
Pass
↓
Continue Program
Tip
Pass means "Nothing happens here yet."
How Long Has My Program Been Running?
[INSERT BLOCK IMAGE HERE: System Running Time]
This block tells you how long the program has been running.
Example
Program Starts
↓
5 Seconds Pass
↓
Running Time = 5000 ms
Useful for:
Timers
Stopwatches
Games
Countdown systems
Measuring Time Differences
[INSERT BLOCK IMAGE HERE: Time Difference]
Sometimes you want to know how much time has passed.
Example
Save Start Time
↓
Do Something
↓
Calculate Difference
↓
Elapsed Time
Useful for:
Timing races
Measuring events
Performance testing
Creating Timed Actions
[INSERT BLOCK IMAGE HERE: Timer Setup]
Timers help schedule actions automatically.
Example
Wait 5 Seconds
↓
Play Buzzer
Concept
Timer
↓
Wait
↓
Action
Beginner Uses
Alarm systems
Countdown timers
Automated lighting
Schedules
Resetting the Program
[INSERT BLOCK IMAGE HERE: Reset]
Sometimes a project needs to start over.
The Reset block restarts the board or program.
Concept
Program Running
↓
Reset
↓
Start Again
Control + Logic
Control and Logic work together.
Logic asks the question.
Control decides what to do.
Example
Distance < 10?
↓
TRUE
↓
Stop Motors
Concept
Question
↓
TRUE/FALSE
↓
Action
Control + Sensors
Control becomes powerful when combined with sensor data.
Obstacle Detector
Distance < 10
↓
Stop Robot
Temperature Alarm
Temperature > 30
↓
Turn Buzzer ON
Motion Detector
Motion Detected
↓
Flash LED
Traffic Light Simulator
Green LED
↓
Wait 3 Seconds
↓
Yellow LED
↓
Wait 1 Second
↓
Red LED
Skills:
Delay
Timing
Sequences
LED Flasher
Repeat 10 Times
↓
LED ON
↓
LED OFF
Skills:
Repeat
Delay
Loops
Obstacle Stop Robot
Distance Sensor
↓
IF Distance < 10
↓
Stop Motors
Skills:
Sensors
Logic
IF Statements
Countdown Timer
5
4
3
2
1
↓
Play Sound
Skills:
Counting Loops
Timing
Displays
Quick Guide for Students
Need the program to wait?
Use:
Delay
Need to make a decision?
Use:
IF
Need something to repeat?
Use:
Repeat Times
Need to repeat until something changes?
Use:
Repeat While
Need to count numbers?
Use:
For Each Range
Need to stop a loop?
Use:
Break
Need a timer?
Use:
Running Time
or
Timer
Quick Reference
| Family | Main Idea |
|---|---|
| Delay | Wait |
| IF | Make decisions |
| Repeat Times | Fixed repetitions |
| Repeat While | Repeat until condition changes |
| For Each Range | Count through numbers |
| For Each Item | Work through lists |
| Break | Stop loops |
| Pass | Do nothing |
| Running Time | Measure time |
| Timer | Timed actions |
| Reset | Start again |
Summary
In this lesson, you learned how Control blocks organize the flow of a program.
You explored:
Delays
IF statements
Repeat loops
While loops
Counting loops
Lists
Break
Timers
Program Reset
Control blocks help programs decide when, how often, and for how long actions should happen.
Key Takeaway
Control blocks are the traffic lights of your program. They help decide when actions happen, how often they repeat, how long they wait, and when they stop. Without Control blocks, programs would be fast, messy, and impossible to organize!
