Teach lesson
Visual programming with a real Arduino (4/4): mini-controller
Students combine visual-programming inputs, decisions, and outputs to build a mini-controller and document real-board test evidence.
Learning Outcomes
Design a mini-controller with input, decision and output.
Test the program with two defined cases.
Explain the behavior and one reasonable improvement.
Student activity preview
Activity Content
Preview only. In a class session, students can fill in responses and submit their work to the teacher.
Choose the challenge
10 min
A mini-controller is a program that reads an input, decides, and produces an output, repeating in the loop. Choose one of these two base challenges (they use
the built-in LED, no wiring):
In this project, Arduino run first is for preparation that only happens once.
The main part (read input, decide, and act) goes inside Arduino loop forever
because the controller must keep checking the input.
- Threshold indicator: read a potentiometer; if it passes a threshold, the LED
stays steady on; otherwise, the LED blinks slowly.
- Two-mode alert: read a button; if pressed, the LED blinks fast; otherwise,
it blinks slowly.
*Optional extensions (only if your teacher confirms the hardware): use external
LEDs for a traffic light, or a servo motor for two positions. These are not
required.*
Which challenge do you choose? State the input and the output you will use.
Fill the table before you build. Use only one row for your base design and
leave the extra rows empty. In that row, write which input you will read, what
decision or threshold the program will use, which output you will observe, and
how you will know it works.
| Goal | Input | Decision or threshold | Output | How you will know it works |
|---|---|---|---|---|
Build a first version
22 min
Build a small first version. Do not try to make it perfect at first. It must
include: one input reading, one if / else decision, one observable output, and a
wait if the behavior repeats too quickly.
Open
arduino-visual-board.Create the program with blocks inside Arduino loop forever.
Verify / compile. Fix any errors that appear.
Upload into device.
Test two cases: one that triggers one branch of the decision and one that triggers the other.
Example of the "Threshold indicator" challenge (steady on above the threshold,
slow blink below):
Reference diagram for the Threshold indicator challenge. Above the threshold the LED stays steady; below it, the LED blinks slowly.
Arduino loop forever:
if [read analog pin# [A0]] [≥] [threshold]
do:
[set built-in LED] [HIGH] # above the threshold: steady on
else:
# below the threshold: slow blink
[set built-in LED] [HIGH]
[wait] 400 milliseconds
[set built-in LED] [LOW]
[wait] 400 millisecondsDescribe the result of the first version. Include at least two tests with their inputs and what the LED did.
Improve one thing
15 min
Choose one small improvement and apply it:
- Adjust the threshold so it switches where you want.
- Change a wait time so the blink is easier to see.
- Use a repeat N times block to avoid copying blocks.
- Make the two modes easier to tell apart.
What improvement did you make? Why was it needed? What evidence shows that it improved?
Present the controller
13 min
Mini-controller summary
Submit a short explanation (text or screenshot) with:
1. Mini-controller name.
2. Input used.
3. Main decision (and threshold, if any).
4. Observable output.
5. Two tests and their results.
6. One improvement applied or proposed.
What did you learn about programming a real system that is different from programming only on a screen? Think about the difference between "it should work" and "I observed it".