Pneumatics and other actuators
What you’ll learn
- How pneumatics move things with compressed air
- How to drive solenoids safely
- How to use buzzers and lights as outputs
Pneumatics
A pneumatic cylinder pushes a piston out when compressed air enters. You need an air supply (a compressor or a tank, or a hand pump), tubing, and a solenoid valve that an electrical signal opens and closes. Pneumatics are fast and powerful, and good for punching, lifting and soft grippers. FIRST and VEX robots often use them.
Solenoids
A solenoid is a coil with a metal plunger: power on, the plunger pulls in. It’s used for locks, valves and “kickers”.
- Needs much more current than a pin can give: switch it with a transistor or MOSFET.
- Add a flyback diode across the coil. When the coil switches off it produces a voltage spike that can destroy the transistor, and the diode safely absorbs it. The same applies to relays and motors.
Buzzers
| Type | How to use |
|---|---|
| Active buzzer | Beeps at one pitch when given power: digitalWrite(pin, HIGH) |
| Passive buzzer (or small speaker) | Plays any pitch with tone(pin, frequency) |
Lights
- Single LEDs with resistors (see your first circuit).
- Addressable RGB LEDs (WS2812, “NeoPixels”): a whole strip controlled from one pin, any colour per LED, using the Adafruit NeoPixel or FastLED library.
Example: a solenoid circuit
Arduino pin ── 1 kΩ ── transistor base +12 V ── solenoid ── transistor collector, transistor emitter ── GND flyback diode across the solenoid (stripe towards +12 V) Arduino GND joined to the 12 V supply's GNDExample: robot sounds
void beepStartup() { tone(8, 880, 100); delay(150); tone(8, 1320, 150);}void beepObstacle() { tone(8, 440, 60); }Sounds make debugging easier: the robot can “say” which state it’s in without a computer attached.
Try it in the virtual Arduino
Press Start simulator, open the diagram.json tab and replace its contents with the wiring below, then paste the sketch into sketch.ino and press the green ▶.
{ "version": 1, "author": "RoboLearn", "editor": "wokwi", "parts": [ { "type": "wokwi-arduino-uno", "id": "uno", "top": 0, "left": 0, "attrs": {} }, { "type": "wokwi-buzzer", "id": "bz1", "top": -90, "left": 150, "attrs": { "volume": "0.1" } } ], "connections": [ [ "bz1:1", "uno:GND.1", "black", [] ], [ "bz1:2", "uno:8", "red", [] ] ], "dependencies": {}}const int BUZZER = 8;int notes[] = {262, 294, 330, 349, 392, 440, 494, 523}; // C D E F G A B C
void setup() { for (int i = 0; i < 8; i++) { tone(BUZZER, notes[i], 200); delay(250); }}
void loop() {}Runs on Wokwi, free, no account needed.
Reverse the scaleEasy
Play the scale from high to low.
Loop backwards: for (int i = 7; i >= 0; i--).
SirenMedium
Make a siren that sweeps the pitch up from 400 Hz to 1,200 Hz and back, forever.
Show an answer
void loop() { for (int f = 400; f <= 1200; f += 10) { tone(8, f); delay(5); } for (int f = 1200; f >= 400; f -= 10) { tone(8, f); delay(5); }}Why the diode?Hard
Explain in your own words why a flyback diode is needed across a solenoid or relay coil. When the current through a coil is suddenly switched off, its magnetic field collapses and creates a high voltage spike. The diode gives that energy a safe loop to flow round, instead of it breaking down the transistor.
Quick check
Finished this lesson?