0Pricing
Arduino & IoT Academy · Lesson

digitalWrite HIGH & LOW

Turn a pin on and off to light an LED.

digitalWrite HIGH & LOW is a free Arduino & IoT Academy lesson on CoddyKit — lesson 2 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.

Now Make It Glow

Your pin is set to OUTPUT, but it is still silent. To actually switch it on or off, you use one new command: digitalWrite. ✨

Two States Only

A digital pin lives in just two states. It is either fully on, called HIGH, or fully off, called LOW. There is nothing in between.

HIGH Means On

Writing HIGH pushes the pin up to roughly 5 volts. That voltage flows through your LED and lights it. HIGH is the on signal.

digitalWrite(ledPin, HIGH);

LOW Means Off

Writing LOW drops the pin back to 0 volts. With no voltage to push current, the LED goes dark. LOW is the off signal.

digitalWrite(ledPin, LOW);

The Two Arguments

digitalWrite needs two things: which pin to change, and the state to set. So you pass a pin and then either HIGH or LOW.

digitalWrite(pin, HIGH);

It Belongs in loop

You set a pin's mode once, but you can change its state any time. Put digitalWrite in loop() to switch the LED on demand.

On Then Off

To blink, you simply alternate. Drive the pin HIGH, then drive it LOW, and the LED toggles between glowing and dark.

digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);

Too Fast to See

Run HIGH then LOW with nothing between and the LED flickers far too fast for your eyes. You need a pause, which comes next lesson.

1 and 0 Also Work

HIGH and LOW are just friendly names. Under the hood they equal 1 and 0, so digitalWrite(pin, 1) does the same as HIGH.

Read Back the State

digitalWrite changes a pin but never reports it. To check what an output pin is doing, you track the state yourself in a variable.

Mind the Wiring

The onboard LED needs no parts, but an external one can pull too much current. Always protect it with a resistor, covered soon.

Quick Check

Your LED is connected and the pin is OUTPUT. How do you turn it off?

Recap

You now control a pin with digitalWrite, using HIGH for on and LOW for off. Next you will add timing so the blink is actually visible. 🎉

Frequently asked questions

Is the “digitalWrite HIGH & LOW” lesson free?

Yes — the full text of “digitalWrite HIGH & LOW” 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 “digitalWrite HIGH & LOW”?

Turn a pin on and off to light 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 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “digitalWrite HIGH & LOW” 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.

All lessons in this course

  1. pinMode and OUTPUT
  2. digitalWrite HIGH & LOW
  3. delay() and Blink Timing
  4. Wire an External LED Safely
← Back to Arduino & IoT Academy