## What We’ll Do Today
Welcome! Today we’re exploring a tiny computer called the **Micro:bit**. It helps us learn how to use code to control lights, buttons, and sensors.
We’ll:
- Discover what the Micro:bit is
- Use a coding tool called **MakeCode**
- Write and test our first program
- Run it on a real Micro:bit
---
## Getting to Know the Micro:bit
We’ll begin by exploring the Micro:bit. It has:
- A grid of LED lights
- Buttons A and B
- Gold edge pins
- Sensors for motion and light
We’ll discuss what each part does and where we’ve seen similar technology around us.
---
## Exploring MakeCode
We’ll visit [makecode.microbit.org](https://makecode.microbit.org) and create a new project.
Students will learn:
- Where to find coding blocks
- How to build programs using drag-and-drop
- How to test code with the built-in simulator
We’ll use simple, block-based coding — like building with digital LEGO bricks.
---
## Writing Our First Program
We’ll write a simple program that:
- Shows an icon (like a heart) when the Micro:bit starts
- Displays a message when a button is pressed
Then students can explore:
- Changing icons or messages
- Trying new inputs like shaking the Micro:bit
---
## Trying It on the Real Micro:bit
We’ll connect the Micro:bit to the computer and:
1. Download the code
2. Transfer it to the Micro:bit
3. Test it by pressing buttons or moving the device
If anything doesn’t work, we’ll go over the steps together.
---
## Wrap-Up & Sharing
To finish, we’ll reflect on the day:
- What did you make your Micro:bit do?
- What do you want to try next time?
Students can show their devices in action and share what they enjoyed most.
---
We’re excited to keep exploring coding and technology together!
---
We’re excited to begin this fun journey into coding and tech!
Welcome! Today, we’re learning about **variables** — a simple but powerful way to help your Micro:bit **remember and work with information**.
Let’s find out what variables are, why we use them, and how we can build fun programs using them.
---
## What Is a Variable?
A **variable** is like a labeled box that stores something — like a number, word, or message. You can change what’s inside the box whenever you want.
Examples:
- A box called `score` can start at 0 and go up by 1 every time you win a game.
- A box called `name` can hold your name and display a greeting like “Hello, Sam!”
Variables help your Micro:bit remember things and make decisions.
---
## What You’ll Learn Today
- What a variable is
- How to make and name variables in MakeCode
- How to store and change values
- How to use variables in fun Micro:bit projects
- How variables help your program think and react
---
## Activity 1: Digital Dice
Show a random number between 1 and 6 everytime the dice is rolled by pressing the button A.
### 1. Create the Variable
- Click **Variables** → **Make a Variable**
- Name the variable: `roll`
### 2. Set Up the Button Input
- Drag the `on button A pressed` block into the workspace
- This block will run the code every time you press button A on the Micro:bit
### 3. Fill the Variable with a Random Number
- Inside the `on button A pressed` block, add a `set roll to` block
- Go to **Math** → drag `pick random 1 to 6` and place it in the `set roll to` slot
- Now, when button A is pressed, `roll` stores a random number between 1 and 6 — just like a dice roll!
---
### 4. Show the Result
- Add a `show number` block under the `set roll to` line
- From the **Variables** menu, drag `roll` into the `show number` block
- This will display the random number stored in `roll` on the Micro:bit’s LED screen
---
## Activity 2: My Multiplication Bot
Let’s make a program that gives you a random multiplication question, then shows the answer when you’re ready.
### What You’ll Need:
- Two variables: `num1` and `num2`
### Steps:
1. Open a new project at [makecode.microbit.org](https://makecode.microbit.org)
2. Click **Variables** → **Make a Variable** → Name it `num1`
3. Repeat to make a second variable: `num2`
4. In the `on start` block, set both variables to random numbers between 1 and 10
5. Add an `on button A pressed` block:
- Show `num1`
- Show the "x" sign using `show string "x"`
- Show `num2`
6. Add an `on button B pressed` block:
- Use the `show number` block to display the answer: `num1 × num2`
You’ve now built a mini math quiz bot!
---
### Wrap-Up
You’ve just learned how to use **variables** to make your Micro:bit smarter and more interactive. Keep practicing at and bring your best creation to share next class!
Happy coding!
# Micro:bit Lesson 3 – Events and Loops
Welcome to Lesson 3! Today, we’re learning how to make our Micro:bit more **interactive and animated** using two powerful ideas in programming: **Events** and **Loops**.
---
## What You’ll Learn Today
- What an **event** is, and how it lets your program react (like pressing a button)
- What a **loop** is, and how it helps repeat actions over and over
- How to use the **pause** block to control the speed of animations
- How to combine images, animations, and simple logic to make Micro:bit games
---
## Key Concepts
### What is an Event?
An **event** is something that happens — like pressing a button or shaking the Micro:bit. You can write code that only runs **when** that event happens.
Examples of events:
- `on button A pressed`
- `on shake`
- `on start` (runs when the program begins)
---
### What is a Loop?
A **loop** tells the computer to do something **again and again**.
Types of loops:
- `forever` → keeps repeating
- `repeat X times` → repeats for a set number of times
Loops are great for making:
- Animations
- Flashing icons
- Repeating patterns
---
## Activity 1: LED Animation Loop
Let’s create a simple animation using loops and LED patterns.
### What You’ll Do:
- Show a sequence of 2–3 images
- Use `pause` blocks to control how fast they change
- Repeat them using a loop
### Steps:
1. Open MakeCode and start a new project
2. Use a `forever` loop
3. Inside the loop, add multiple `show leds` blocks with different patterns
4. Add a `pause` (e.g., 500 ms) after each pattern
5. (Optional) Add `clear screen` for a cleaner animation effect
Now you’ve made a repeating animation!
---
## Activity 2: Button-Controlled Animation
Let’s make the animation play **only when a button is pressed**.
### Steps:
1. Replace the `forever` loop with `on button A pressed`
2. Inside this block, use a `repeat 4 times` loop
3. Add the same LED pattern + pause combination
4. Now your animation runs just once — each time you press A
---
Welcome to Lesson 4! Today, we’ll learn how to draw using the Micro:bit’s LED screen — just like a tiny drawing board made of lights.
---
## What You’ll Learn Today
- How the Micro:bit screen is a **grid of 25 lights** (5 rows × 5 columns)
- How to turn lights on by choosing the right **X and Y positions**
- How to use **loops inside loops** to draw many dots quickly
- How to create patterns and animations using repeat blocks
---
## Key Idea 1: What Is the LED Grid?
The Micro:bit has **25 tiny lights** in a square grid.
We can light them up using numbers called **coordinates**.
- **X-axis** (left to right): 0 to 4
- **Y-axis** (top to bottom): 0 to 4
Think of it like this:
We use `plot x y` blocks to turn lights on!
---
## Activity 1: Diagonal Line
Let’s light up a diagonal line across the screen.
### What You’ll Build:
- A line from top-left to bottom-right using the same number for X and Y.
### Step-by-Step (in MakeCode):
1. Start a new project
2. Go to **Loops** → drag `repeat 5 times` into the workspace
3. Inside that, go to **Variables** → `make a variable` → name it `i`
4. Add `set i to 0` before the loop
5. Inside the loop:
- Use `plot x y` block → set X to `i`, Y to `i`
- Add `change i by 1` at the end of the loop
6. Press "play" to watch the diagonal light up!
---
## Activity 2: Light Up the Grid (Nested Loops)
Now let’s light up the whole grid row by row using two loops — one for **rows** and one for **columns**.
### What You’ll Build:
- A full-screen lighting effect using two loops.
### Step-by-Step (in MakeCode):
1. Start a new project
2. Drag a `forever` block from **Basic**
3. Inside it, drag a `repeat 5 times` block (this will be for Y)
- Make a variable called `y`
- Before the loop, set `y to 0`
4. Inside that loop, add another `repeat 5 times` block (for X)
- Make a variable `x`
- Before this loop, set `x to 0`
5. Inside the inner loop:
- Use `plot x y`
- Add `change x by 1`
6. After the inner loop, add `change y by 1`
7. Add a `pause (100 ms)` after each row lights up
Now the lights will fill the screen row by row!
(Optional: use `clear screen` and repeat to animate)
## Wrap-Up
Great job! Today, you learned:
- How the Micro:bit’s LED screen uses **coordinates**
- How to use **loops** to repeat drawing steps
- That loops inside loops help us draw rows and columns
Next time, we’ll add more interaction — like using buttons to control drawings!
Keep exploring and drawing with lights!
# Micro:bit Lesson 5 – Light Sensors
Today we’re learning about **sensors** — special tools that help the Micro:bit feel what’s happening in the world around it. We’ll focus on the **light sensor**, which tells us how bright or dark a place is.
---
## What You’ll Learn Today
- What a **sensor** is, and why we use them in technology
- How the **Micro:bit light sensor** works
- How to use blocks in MakeCode to read the **brightness level**
- How to create simple programs that respond to light
---
## What Is a Sensor?
A **sensor** is like a tiny helper that tells a computer what’s going on around it.
Examples:
- A **light sensor** tells how bright or dark it is
- A **temperature sensor** tells how hot or cold
- A **motion sensor** knows when something moves
The Micro:bit has sensors built right into it!
---
## Micro:bit’s Light Sensor
The Micro:bit’s **LED screen** is also a light sensor!
It can **measure how much light** is falling on the device.
- In a **bright room**, the value is high
- In a **dark place**, the value is low
We can use the **`light level`** block to get this number and decide what to do with it in our code.
---
## Activity 1: Check Room Brightness
Let’s build a simple program that shows the current light level on the Micro:bit’s screen.
### What You’ll Build:
- A loop that keeps checking how bright the room is
- The number will update again and again
### Steps in MakeCode:
1. Start a new project
2. Drag out a `forever` block
3. Inside it, add:
- `show number` block (from **Basic**)
- Inside that, place `light level` block (from **Input**)
4. Add a `pause (500 ms)` after it, so it updates every half second
➡️ Now your Micro:bit acts like a live light meter!
Try shining a flashlight or covering it with your hand to see the numbers change.
---
## Activity 2: Light Alarm
If the light level drops too low (like someone turning off a light), show a warning!
**Hint:**
- Use `if light level < 50 then`
- Show a message like “Too Dark!”
## Activity 3: Read Light Only on Button Press
Now let’s build a version where the Micro:bit only checks light **when you press Button B**.
### What You’ll Build:
- Pressing Button B will show the light level just once
### Steps in MakeCode:
1. Drag out an `on button B pressed` block
2. Inside it, add:
- `show number` block
- Place `light level` block inside it
Now you can check the light level *only when you want* — by pressing B!
---
* Learn to use the accelerometer sensor to detect gestures such as free fall, tilt, shaking, etc.
* Learn to sense any other motion on Microbit.
# Micro:bit – Sound & Music with Micro:bit
Today’s lesson is all about **sound**! We’ll explore how to make the Micro:bit **play sounds**, and how it can **listen to sounds** using its built-in microphone.
---
## What You’ll Learn
- How to use the **built-in speaker** on the Micro:bit
- How the **microphone** detects sound around you
- How to write code that **plays music or reacts to noise**
- Build simple programs that play tones or detect claps
---
## Key Concepts
### 1. Built-in Speaker
The Micro:bit V2 has a small speaker built into the board — no wires or headphones needed! We can use the **Music blocks** in MakeCode to:
- Play notes
- Play melodies
- Add fun sound effects to animations or games
---
### 2. Built-in Microphone
The Micro:bit also has a microphone, which can **hear sounds** around it. We can measure:
- **Sound level** (how loud it is)
- Listen for **sudden sounds** like a clap or shout
We use the `sound level` block to measure how loud it is, and `on loud sound` block to run code when it hears something.
---
## Activity 1: Make the Micro:bit Sing!
Let’s play a short melody through the speaker.
### Steps (MakeCode):
1. Open a new project
2. Drag out the `on start` block
3. Inside it, go to **Music** → add `play melody` block
4. Pick a built-in tune like `"ba ba ba ba ba"` or `"C D E F G"`
5. Press the reset button — your Micro:bit sings on start!
---
## Activity 2: Sound Level Meter
Let’s check how loud the room is and show it as a number.
### Steps (MakeCode):
1. Drag out a `forever` block
2. Inside it, add:
- `show number` block
- Place `sound level` block inside it (from **Input**)
3. Add `pause (100 ms)` to slow it down
4. Optional: try clapping or talking near the Micro:bit to see the number change
---
## Activity 3: Clap to Trigger a Sound
Let’s code the Micro:bit to **listen for a loud sound** (like a clap) and play a beep or melody in response.
### Steps (MakeCode):
1. Drag out `on loud sound` block (from **Input**)
2. Inside it, add a `play tone` or `play melody` block from **Music**
3. Test it by clapping or tapping the table nearby
Try customizing:
- Use `show icon` or `show string` when sound is detected
- Change the melody or play a sound effect
---
## Wrap-Up
Awesome job! Today, you explored:
- The Micro:bit’s **speaker** and how to play music
- The **microphone**, which listens to sounds around it
- How to build fun programs that **respond to real-world sound**
Next time, we’ll mix sound with lights and logic to make even smarter projects!
* Learn about Microbit’s built-in magnetometer sensor.
* Learn to use this sensor to detect the magnetic force around Microbit and code Microbit to create many useful applications.
* Learn about Microbit’s built-in temperature sensor.
* Learn to use Microbit to take temperature readings.
* Create a real-time application of the Microbit accelerometer.
* Tak
e readings/make observation chart to use real-time sensor values in the application made.