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.

Grades 6–1260–90 minutesBuild + codeNo solder required
← Back to Engineering
BENCH UNIT 025V LOGIC
Waiting for output…Try the PWM dimmer and the digital buzzer.
PWM BRIGHTNESS
DIGITAL BEEP

Core 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:

1 · System decision

What just happened in the code—an event, a threshold, a countdown, a state change?

2 · Actuation method

What physical phenomenon makes it real—light, sound, heat, motion, or force?

3 · Human perception

What does a person notice, and does the intensity match how important it is?

Signal vocabulary

Three ways an output can speak

Digital

Two states

Fully on or fully off—a relay click, a buzzer beep, an LED at full brightness. Best for clear events.

PWM (analog-ish)

A range

Brightness, speed, or angle. A digital pin fakes an in-between value by switching fast.

Pattern

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.

+ 5V −

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.

Build recipes

Make four low-cost outputs

Use only low-voltage classroom electronics. Confirm polarity and current before connecting a microcontroller.

Blinking beacon

10 min
  1. Wire an LED in series with a 220 Ω resistor from a digital pin to ground.
  2. Blink it at a fixed interval, then try a distress pattern instead of steady on/off.
  3. Fade it in and out with analogWrite instead of a hard blink.
  4. Compare how each pattern reads from across the room.

Alarm buzzer

10 min
  1. Connect a small active buzzer directly to a digital pin and ground.
  2. Trigger one short beep on an event, not a held tone.
  3. Add a second, longer pattern for a more urgent event.
  4. Test whether the two patterns are easy to tell apart by ear alone.

Servo flag signal

15 min
  1. Attach a small paper or cardboard flag to a servo horn.
  2. Sweep the servo between two named angles, like “clear” and “stop.”
  3. Add a third, in-between angle for a “caution” state.
  4. Power the servo from its own supply if it jitters on shared power.

Haptic wristband

20 min
  1. Mount a vibration motor through a transistor driver, not directly on a pin.
  2. Add a flyback diode across the motor leads.
  3. Trigger a short pulse for a normal alert, a longer one for urgent.
  4. Test it silently in a pocket or sleeve—does the pattern still read?
Safety boundary: Never wire a relay's high-voltage side to wall power, outlets, or mains wiring without direct teacher supervision and proper enclosures. Power motors, solenoids, and relay coils from a separate low-voltage supply, always share a common ground, and never exceed a component's rated voltage or current.

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.

≈ 14 mAGood — comfortably bright and safe

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.

A transistor driving a DC motor from a separate supply, protected by a flyback diodeA microcontroller pin connects through a base resistor to an NPN transistor, which switches motor current between a separate power supply and common ground; a diode is wired backward across the motor. MICROCONTROLLER PIN 9 GND 220 Ω base R NPN M flyback diode +V COMMON GROUND
PartJob
Base resistorLimits the small current the pin has to supply
TransistorLets that small current switch a much larger one
Flyback diodeAbsorbs 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

OSCILLOSCOPE · 4 CYCLESPWM SIGNAL AT PIN

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

TIMER→LED→STEADY + VISUAL

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

Proportional

Match reaction intensity to importance—a brief blink for status, a sustained alarm for danger.

Perceivable

Use more than one channel when the message truly matters—light and sound together.

Fail-safe

Choose a default the actuator can hold forever if the code crashes—relay open, motor off.

Protected

Current-limit and flyback-protect every real-world load; never trust code alone to keep current safe.

Non-blocking

Don't freeze the whole program waiting for a buzzer or motor to finish its cycle.

Repairable

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.

Constraint

Drive at least one output through a resistor or transistor you sized yourself. Low voltage only.

Evidence

Test it with three people. Record whether they could read the value without being told the scale.

Iteration

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?