pinMode and OUTPUT
Tell a pin it will drive current to an LED.
pinMode and OUTPUT is a free Arduino & IoT Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Pins Have a Job
Every Arduino pin can either listen or speak. Before you use one, you must tell it which job to do. That setup is the role of pinMode. 🔌
Why OUTPUT Mode
To light an LED, the pin must send current out into the world. You declare that intent by setting the pin to OUTPUT mode.
The pinMode Call
You configure a pin once, inside setup(). The pinMode function takes a pin number and a mode, and it remembers your choice.
pinMode(13, OUTPUT);Naming Your Pin
Hard-coded numbers get confusing fast. Give the pin a clear name with a constant so your sketch reads like plain language.
const int ledPin = 13;Set It Up Once
You only need to declare a pin's mode a single time. Put pinMode in setup(), which runs once when the board powers on.
void setup() {
pinMode(ledPin, OUTPUT);
}The Onboard LED
Pin 13 is special: most Arduino boards wire it to a tiny onboard LED. That means you can test output with no extra parts. 💡
A Friendlier Alias
You do not have to memorize the number. Arduino gives you the built-in name LED_BUILTIN, which points to that onboard LED for you.
pinMode(LED_BUILTIN, OUTPUT);OUTPUT vs INPUT
Each pin defaults to listening. Setting OUTPUT flips it so the pin actively drives a voltage instead of just sensing one.
What 'Drive' Means
An OUTPUT pin can push out about 5 volts or pull down to 0. That controlled push is how a pin drives an LED on or off.
Forgetting pinMode
Skip pinMode and your LED may stay dim or dead. The pin never enters OUTPUT mode, so it cannot push enough current to shine.
Setup Is the Stage
Think of setup() as preparing the stage before the show. Declaring your pin's mode here gets everything ready for the loop that follows.
Quick Check
You want a pin to light an LED. What do you call first?
Recap
You learned to claim a pin with pinMode and OUTPUT inside setup(). With the pin ready to drive current, you can now make it blink. 🎉
Frequently asked questions
Is the “pinMode and OUTPUT” lesson free?
Yes — the full text of “pinMode and OUTPUT” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.
What will I learn in “pinMode and OUTPUT”?
Tell a pin it will drive current to an LED. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Arduino & IoT Academy?
No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “pinMode and OUTPUT” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Arduino & IoT Academy lesson?
Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.