Learning Objective
Switch a light on and off from the web page, dim it, and explain how the dimming works.
Hello World & PWM Dimming


Hardware: On-board Single LED (same position on your MakerBuddy)


Dashboard: LED Control Card
See How the Single LED Works
Read the picture from left to right: the command → what happens inside → the result.

1 · What it receives
An on/off command, or fast PWM pulses.
2 · How it works
Current flowing through it one way makes light. Fast PWM switching sets how bright it looks: more on-time looks brighter.
3 · Why it matters
A small light can show status or make a warning easy to see.
Where might we use it?
- Status lights
- Night lights
- Warning lights
Student sentence: An LED turns electricity into light, and PWM sets how bright it looks.
Teacher/parent prompt: Ask, “What goes in on the left, what happens inside, and how does it help someone?”
Theory: Digital Logic
On or Off: Digital Signals
An analog signal can have any value in a range. A digital signal has only two states: HIGH (1, which is 3.3V on MakerBuddy's ESP32) and LOW (0, which is 0V). Every computer works with these two states. So an LED used as a digital output is either fully ON or fully OFF. Later in this lesson, PWM gives us the brightness in between.
How LEDs Work
LED means Light Emitting Diode. It has polarity: a positive side and a negative side. Electricity can flow through it in only one direction. The longer leg is positive (anode). The shorter leg, on the flat side of the plastic rim, is negative (cathode). Put an LED in backwards and it stays dark, and it can be damaged.
Digital Output on MakerBuddy
The single LED is already built into your MakerBuddy IoT Board, so there is no wiring. Flip the switch on the dashboard and the LED turns ON or OFF almost at once. That is a digital output.
For Teachers
Blinking an LED is the electronics version of "Hello World", the first program in any language. Link ON/OFF to binary 1/0. If you have a loose LED and a battery, show that it lights only one way round.
For Parents
This week your child controls their first electronic part. They learn that digital things are either ON or OFF, the idea behind every phone and computer. LEDs are everywhere, from TV remotes to phone screens.
Theory: Pulse Width Modulation (PWM)
From ON/OFF to Dimming: The PWM Trick
PWM switches the LED on and off very fast. Your eyes see the average, so the LED looks dimmer.
Understanding Duty Cycle
Duty cycle is how much of the time the signal is ON: 100% is fully on, 50% is on half the time, 0% is off. The LED switches about a thousand times every second, so you see a steady glow, not flicker. At 50% the LED gives half the light, though it usually looks brighter than half.
PWM on the ESP32
On the dashboard, the Brightness (PWM) slider goes from 0 (off) to 255 (full) and shows the number as PWM: N. It works only while the LED is switched on. To get the percentage, divide the PWM number by 255: PWM 26 is about 10%, 64 about 25%, 128 about 50% and 255 is 100%.
Real-World Applications
Light dimmers at home, motor speed, speakers, and the screen brightness on phones and laptops.
For Teachers
PWM shows how an ON/OFF pin can act like a dimmer by using time. It links digital and analog, a key engineering idea.
For Parents
PWM is the same trick behind dimmer switches at home and the brightness setting on your phone.
Try It: Dim the LED
Interactive demo · no kit needed
Play with a pretend MakerBuddy board and its web page, right here.
Follow the steps one at a time. Got the kit? You can switch to the real board inside.
Hands-On Activity: LED Control
Activity Duration: 15-20 minutes
Control the board's LED from the dashboard and watch the real board answer straight away.
Step-by-Step Instructions:
- Locate the LED: Find the single LED on the board, next to the label 12-LED. No wiring needed.
- Access LED Card: On the dashboard, find the LED Control card. It has an LED On/Off switch and a Brightness (PWM) slider.
- First Toggle: Click the switch. The LED on the board lights up.
- Toggle OFF: Click again. The LED goes off.
- Rapid Toggling: Click quickly a few times. The LED keeps up with almost no delay.
- Test From Multiple Devices: If you can, open the dashboard on a second phone or computer on the same network and control the LED from there. The other screen updates within about 2 seconds.
- Locate the Brightness Slider: Turn the LED ON again and find the Brightness (PWM) slider below the switch. It won't move while the LED is off.
- Minimum Brightness: Slide to about PWM: 26 (10%). The LED is very dim but still on.
- Half Brightness: Set it to about PWM: 128 (50%). Compare it with full brightness.
- Full Brightness: Slide to PWM: 255 (100%), the brightest it goes.
- Smooth Dimming: Slide slowly from PWM 0 to PWM 255 and back. The light changes smoothly.
What Students Should Observe:
- The LED answers a dashboard click almost instantly
- The dashboard switch matches the real LED
- The LED can be any brightness, not just ON or OFF
Challenge
Challenge 1: Brightness Target Practice
Set the LED to 10% (about PWM 26), then 50% (PWM 128), then 100% (PWM 255). How different do they look?
Challenge 2: Dimming SOS Signal
Send SOS with brightness instead of ON/OFF. Keep the LED switched ON, use only the slider, and rest at PWM 0 (dark) between flashes:
- Dots: Dim flash, 25% (about PWM 64), for about 0.5s
- Dashes: Bright flash, 100% (PWM 255), for about 1.5s
When you finish, slide back to PWM 255 so the LED lights fully in Challenge 3.
Challenge 3: Human Telegraph
Morse code sends messages with short dots (·) and long dashes ( - ). Send an SOS with the LED switch:
SOS: · · · - - - · · ·
Instructions:
- Dot (·): LED ON for about 0.5 seconds, then OFF
- Dash ( - ): LED ON for about 1.5 seconds, then OFF
- Letter Gap: Wait about 1 second between letters
- Pattern: 3 short, 3 long, 3 short
Bonus Challenge: Look up the Morse code alphabet and send your initials. Can you make a repeating pattern that spells your name?
Success Criteria: A classmate who can't see your screen recognizes SOS from the LED alone.
Key Takeaways
✓ Digital Logic (HIGH/LOW)
Digital signals have two states: HIGH (1, 3.3V on MakerBuddy) or LOW (0, 0V). Every computer is built on this.
✓ LED Operation
An LED lights when electricity flows through it the right way. LEDs are in indicator lights, phone screens and car lights.
✓ Polarity
Polarity means having a positive and a negative side, like an LED's two legs. Connected backwards, an LED stays dark and can be damaged.
✓ Real-time Control
The dashboard keeps a live connection (a WebSocket) open to the ESP32 and sends each click as a tiny message, which the ESP32 acts on in milliseconds.
✓ PWM (Pulse Width Modulation)
PWM switches a pin on and off very fast, so an LED looks dimmer or a motor runs slower.
✓ Duty Cycle
The share of time the signal is ON, from 0% to 100%. It sets how bright an LED looks or how fast a motor runs. At 50% it is ON half the time.
Coming Up Next Week:
Week 5: The Physics of Color (RGB LED)
Learning Support
Use this quick guide to help every learner understand, practice and explain Hello World & PWM Dimming.
For students
Try it in three steps
- Say it: explain the main idea in one simple sentence.
- Show it: Toggle the onboard LED and dim/brighten it using the Brightness (PWM) slider on the LED Control card.
- Stretch it: Set brightness levels to 10%, 50% and 100% (PWM 26, 128 and 255), and send a dimming SOS pattern.
Checkpoint: What was your input, what decision or process happened, and what was the output?
For teachers & parents
Coach without taking over
- Before: ask the learner to predict what will happen and why.
- During: use prompts such as “What changed?” and “What could you test next?” instead of giving the answer.
- After: ask for a 30-second explanation, one piece of evidence and one improvement.
Look for: safe handling, correct vocabulary, a result the learner can demonstrate, and an explanation in their own words.
Did you get it?
Three quick questions. Pick an answer to see whether it is right, and why.
1How does the dimming trick (PWM) make an LED look dimmer?
2What does a 50% duty cycle mean?
3Why does an LED connected backwards not light up?
