Robotics Enrichment Program
Engineering Robots: Build, Wire, Code!
Get ready to build your own robots from the ground up! In Engineering Robots: Build, Wire, Code! you’ll design, assemble, and program robots that move, sense, and respond to the world around them. You will learn how different parts, including motors, sensors, and circuits, work together and bring your robot ideas to life through hands-on building and coding. No experience needed—just curiosity and creativity!
Skills You’ll Develop
- Building and wiring real robots using motors, sensors, and controllers
- Programming robots to move and react to their surroundings
- Problem-solving and teamwork through design challenges
- Creative thinking and perseverance while engineering your own designs
Session 2: Sensing the World with IR Sensors
Goal: Connect an IR (Infrared) sensor to the micro:bit and learn the difference between analog and digital readings.
What is an IR Sensor?
An IR (Infrared) sensor can detect objects in front of it using infrared light. It’s like giving your micro:bit the ability to “see”! IR sensors are used in:
- Robots to avoid obstacles
- Automatic doors
- Line-following robots
- Proximity detection
Your IR sensor has 3 pins:
- VCC - Power (connects to 3V)
- GND - Ground (connects to GND)
- OUT - Signal output (connects to Pin 0, 1, or 2)
Connecting the IR Sensor
Components You’ll Need:
- micro:bit
- IR sensor module
- 3 alligator clips or jumper wires
- Battery pack (optional, for portability)
Wiring Steps:
-
Connect Power
- Connect IR sensor VCC pin to micro:bit 3V pin (using red wire/clip)
-
Connect Ground
- Connect IR sensor GND pin to micro:bit GND pin (using black wire/clip)
-
Connect Signal
- Connect IR sensor OUT pin to micro:bit Pin 0 (using yellow/white wire/clip)
Safety Check: Before powering on, verify all connections with your teacher!
Understanding Digital vs Analog Readings
Sensors can send data in two ways:
Digital Reading:
- Only two values: 0 (LOW/False) or 1 (HIGH/True)
- Like an on/off switch
- 0 = Object detected
- 1 = No object detected
Analog Reading:
- Range of values: 0 to 1023
- Like a dimmer switch
- Higher numbers = object is farther away
- Lower numbers = object is closer
- More precise than digital!
Programming the IR Sensor
Activity 1: Digital Reading (Simple Detection)
Setup:
- In MakeCode, go to Advanced → Pins
- In the
on startblock, addshow numberto display which pin you’re using - Create a
foreverloop
In the forever block:
- Add an
if...then...elsestatement - From Pins, drag
digital read pin P0into the if condition - Set the condition to: if
digital read pin P0= 0 - Then (object detected):
- Show icon “X”
- Play a sound (from Music)
- Else (path is clear):
- Show icon “✓” (checkmark)
Test it: Wave your hand in front of the sensor! You should see an X and hear a sound when an object is detected, and a checkmark when the path is clear.
Activity 2: Analog Reading with Sound Alert
Setup:
- Create a new project or delete the previous code
In the forever block:
- Add an
if...then...elsestatement - Set the condition to: if
analog read pin P0< 300 - Then (object is close):
- Show icon “X”
- Play a sound (from Music)
- Else (object is far):
- Show icon “✓” (checkmark)
- Add a
pause 100 msblock at the end
Experiment:
- What happens when you move your hand closer or farther?
- Try adjusting the 300 value - what happens if you use 500? Or 200?
- Can you find the best threshold value for detecting objects?
🎯 Challenge: Build an Obstacle Alert System
Your Task: Create a system that warns when an obstacle is getting too close!
Requirements:
- Use analog reading to measure distance
- When object is FAR (>700): Show a checkmark, no sound
- When object is MEDIUM (400-700): Show a small square, play a slow beep
- When object is CLOSE (<400): Show a large square, play a fast beep
- Add button A to display the current sensor reading as a number
- Add button B to pause/resume the system
Hints:
- You’ll need multiple
if...then...else if...elsestatements - Use the Music blocks for different beep speeds
- Use Input blocks for button presses
- Create a variable called
systemActiveto track if the system is on or off
Testing Ideas:
- Test with different objects (hand, book, wall)
- Find the maximum detection distance
- See if different colored objects give different readings
Key Concepts You Learned
- How to connect a 3-pin sensor to micro:bit
- Difference between digital (0 or 1) and analog (0-1023) readings
- Using conditional statements to create detection zones
- Building a practical sensing system
Think About It:
- Where could you use an obstacle detector in real life?
- What other sensors could you add to make it better?
- How could this help a robot navigate?
Session 1: Introduction to micro:bit
Goal: Get familiar with the micro:bit, learn basic programming, and create your first interactive programs.
What is a micro:bit?
The BBC micro:bit is a small, programmable computer with:
- LED display (5×5 grid)
- Two buttons (A and B)
- Built-in sensors (accelerometer, compass, temperature)
- GPIO pins for connecting external components
Getting Started
-
Access the Editor
- Go to makecode.microbit.org
- Click New Project and give it a name
-
Interface Overview
- Left: Simulator showing your micro:bit
- Middle: Block categories
- Right: Programming workspace
-
First Program: Hello World
- From Basic, drag
show stringinto theon startblock - Type “Hello!” in the text field
- Click the simulator to see it run
- Download to a real micro:bit (connect via USB)
- From Basic, drag
-
Interactive Program: Button Counter
- From Input, drag
on button A pressed - Inside it, add
show numberwith a variable - Use Variables to create a counter that increases each press
- Add button B to decrease the counter
- From Input, drag
-
Sensor Exploration
- Use the accelerometer to detect shaking
- Display different images when tilted left/right
- Show temperature readings on the LED display
🎯 Challenge: Dice Rolling Game
Create a game where you shake the micro:bit to “roll a dice” and display a random number from 1 to 6.
Resources
Safety Reminders
- Always disconnect power before making circuit changes
- Check all connections with teacher before powering on
- Keep wires away from moving parts
- Use appropriate resistors to protect components
- Work carefully and ask questions if unsure