What just happened in the code—an event, a threshold, a countdown, a state change?
Engineering · Physical Computing · Design Lab
Outputs: Beyond the LED
An LED shows what your code decided. Motors, buzzers, and solenoids can show it too, as motion, sound, and force. Learn to drive each one safely, with the right driver circuit for the load.
← Back to EngineeringCore idea
An output is a change the system creates
The physical result can be a blinking LED, but it can also be a beep, a buzz, a spinning wheel, a moving arm, or a switched-on lamp. Good output design connects three layers:
What physical phenomenon makes it real—light, sound, heat, motion, or force?
What does a person notice, and does the intensity match how important it is?
Signal vocabulary
Three ways an output can speak
Two states
Fully on or fully off—a relay click, a buzzer beep, an LED at full brightness. Best for clear events.
A range
Brightness, speed, or angle. A digital pin fakes an in-between value by switching fast.
Meaning over time
Blink codes, alarm rhythms, or animated sequences. Software turns timing into vocabulary.
Interactive circuit lab
Can this pin drive it directly?
A microcontroller pin can typically supply only about 20–40 mA before it risks damage. Small outputs sip that safely through a resistor. Bigger outputs need a driver—a transistor, MOSFET, or relay—that lets a tiny signal switch a much larger current from its own power supply.
Choose an output, then press drive.
Idea gallery
Ten actuators that turn code into action
Start with the effect you want a person to notice, then choose an actuator that produces it honestly.
Standard LED
A single-color light that turns on, off, or dims with PWM.
LIGHT · DIGITAL OR PWMRGB LED
Three LEDs in one package—mix red, green, and blue PWM to make any color.
COLOR · THREE-CHANNEL PWMActive buzzer
Has its own oscillator—send power, get one fixed pitch of sound.
SOUND · DIGITALVibration motor
A spinning off-center weight turns electrical current into a buzz you can feel.
HAPTIC · DIGITAL OR PWMServo motor
Holds a precise angle, usually 0–180°, set by pulse timing rather than a plain on/off signal.
POSITION · PULSE TIMINGDC motor + wheel
Spins continuously; speed follows PWM duty cycle and direction follows polarity.
MOTION · PWMStepper motor
Moves in exact fixed steps—precise, repeatable position without a feedback sensor.
PRECISION MOTION · PULSESRelay-switched lamp
A low-power signal clicks a mechanical switch that controls a separate, higher-power circuit.
SWITCHING · DIGITALSolenoid latch
A coil pulls a metal plunger in or out—locks, latches, and stamping mechanisms.
FORCE · DIGITALAddressable LED strip
Each pixel gets its own color over a single data line—animated light from one wire.
ANIMATION · DATA PROTOCOLBuild recipes
Make four low-cost outputs
Use only low-voltage classroom electronics. Confirm polarity and current before connecting a microcontroller.
Blinking beacon
10 min- Wire an LED in series with a 220 Ω resistor from a digital pin to ground.
- Blink it at a fixed interval, then try a distress pattern instead of steady on/off.
- Fade it in and out with
analogWriteinstead of a hard blink. - Compare how each pattern reads from across the room.
Alarm buzzer
10 min- Connect a small active buzzer directly to a digital pin and ground.
- Trigger one short beep on an event, not a held tone.
- Add a second, longer pattern for a more urgent event.
- Test whether the two patterns are easy to tell apart by ear alone.
Servo flag signal
15 min- Attach a small paper or cardboard flag to a servo horn.
- Sweep the servo between two named angles, like “clear” and “stop.”
- Add a third, in-between angle for a “caution” state.
- Power the servo from its own supply if it jitters on shared power.
Haptic wristband
20 min- Mount a vibration motor through a transistor driver, not directly on a pin.
- Add a flyback diode across the motor leads.
- Trigger a short pulse for a normal alert, a longer one for urgent.
- Test it silently in a pocket or sleeve—does the pattern still read?
Reliable wiring · part 1
A resistor decides the current, not the code
An LED is not a resistor—left unprotected, it lets through as much current as the supply and wires allow, which is usually more than it or the pin can survive. Ohm's Law, I = V ⁄ R, tells you how big a series resistor needs to be. Drag to pick a resistor and watch the current and brightness respond.
Source is 5 V, this LED's forward voltage is about 2 V, so the resistor absorbs the other 3 V.
Reliable wiring · part 2
Transistors amplify a signal into force
A GPIO pin cannot safely power a motor, solenoid, or relay coil directly. Wire the pin to the base of an NPN transistor through a resistor. The transistor's collector-emitter path switches the load's much larger current, drawn from a separate supply that shares a common ground with the microcontroller. A flyback diode placed backward across the motor absorbs the voltage spike created when its magnetic field collapses, protecting the transistor from that spike.
| Part | Job |
|---|---|
| Base resistor | Limits the small current the pin has to supply |
| Transistor | Lets that small current switch a much larger one |
| Flyback diode | Absorbs the spike when the motor's field collapses |
const int motorPin = 9;
void setup() {
pinMode(motorPin, OUTPUT);
}
void loop() {
digitalWrite(motorPin, HIGH);
delay(1000);
digitalWrite(motorPin, LOW);
delay(1000);
}
// The pin only ever switches the
// transistor's base — the transistor
// and separate supply do the real work. Faking analog
PWM fakes an in-between value by blinking fast
A digital pin only outputs fully HIGH or fully LOW—there is no in-between voltage to set directly. To get an in-between brightness or speed, code switches the pin on and off many times per second. The fraction of time spent HIGH, the duty cycle, sets the average voltage a motor or LED experiences. Drag the duty cycle and watch the wave, the average voltage, and the LED respond together.
0% is always off, 100% is always on. 50% spends equal time HIGH and LOW.
Average ≈ 2.50 V of 5 V
Design generator
The Output Forge
Combine what just happened, which actuator responds, how the signal is shaped, and which sense it reaches. The best response is not the flashiest one—it is the one that matches how important the event actually is.
Countdown-finished light
Light the LED and hold it until acknowledged. Keep the response visible without demanding attention.
Prototype test: Does the intensity of the response match how important this event actually is?
Trustworthy design
Six principles for outputs people can trust
Match reaction intensity to importance—a brief blink for status, a sustained alarm for danger.
Use more than one channel when the message truly matters—light and sound together.
Choose a default the actuator can hold forever if the code crashes—relay open, motor off.
Current-limit and flyback-protect every real-world load; never trust code alone to keep current safe.
Don't freeze the whole program waiting for a buzzer or motor to finish its cycle.
Keep drivers, fuses, and connectors inspectable and easy to replace.
Design challenge
Build an output that communicates a value
Build one output that shows a changing amount—not just on or off—using light, sound, or motion. Use PWM, a driver circuit, or both, as the load requires.
Drive at least one output through a resistor or transistor you sized yourself. Low voltage only.
Test it with three people. Record whether they could read the value without being told the scale.
Change one variable—duty cycle range, pattern speed, or feedback channel—and test again.
Quick check
Can you drive the output?
1. Why does an LED need a series resistor?
2. What problem does a transistor solve when driving a motor?
3. What does a flyback diode protect against?
4. What does PWM duty cycle actually control?