Skip to content

First LED Blink - Digital Output Basics

Beginning of the lesson

Understanding Digital Output

Digital output is the foundation of controlling electronic devices with a microcontroller. Let's break down what this means.

What is Digital?

In electronics, digital means there are only two possible states:

HIGH

5 Volts (5V)

Logic 1

ON

LOW

0 Volts (0V)

Logic 0

OFF

Think of it like a light switch - it's either ON or OFF, nothing in between!

Pin 13 - The Special Pin

The Arduino Uno has 14 digital pins (numbered 0-13). Pin 13 is special because:

  • It has a built-in LED on the Arduino board itself
  • It has a built-in resistor for that LED
  • Perfect for testing without any external components
  • When connecting external LEDs, you still need a resistor!

Essential Arduino Functions

pinMode(pin, mode)

Configures a pin to behave as an INPUT or OUTPUT.

pinMode(13, OUTPUT);  // Set pin 13 as an output

Parameters:

  • pin: The pin number (0-13 for digital)
  • mode: Either INPUT or OUTPUT

digitalWrite(pin, value)

Sets a digital pin to HIGH (5V) or LOW (0V).

digitalWrite(13, HIGH);  // Turn ON (5V)
digitalWrite(13, LOW);   // Turn OFF (0V)

What happens electrically:

  • HIGH: Pin outputs 5V, current flows through LED, LED lights up!
  • LOW: Pin outputs 0V, no current flows, LED is off

delay(milliseconds)

Pauses the program for a specified time.

delay(1000);  // Wait for 1000ms = 1 second
delay(500);   // Wait for 500ms = 0.5 seconds

Time conversion:

  • 1000 milliseconds = 1 second
  • 500 milliseconds = 0.5 seconds
  • 100 milliseconds = 0.1 seconds
Safety First!
  • Always use a resistor with external LEDs
  • Never exceed 40mA per pin
  • Check LED polarity before powering on
  • Disconnect USB when changing wiring
LED Anatomy
Anode (+) Long Leg Cathode (-) Short Leg Flat Side

The flat side of the LED dome indicates the cathode (-)

Continue this lesson on YourAIZone

The full lesson has the complete explanation, worked examples, common mistakes, tests with instant checking and an AI tutor. Start right away as a guest, or create an account to keep your progress.

In the full lesson

  • The complete explanation
  • Worked examples
  • Common mistakes and how to avoid them
  • Test questions: 15
  • AI tutor that answers questions about the topic
  • Progress tracking for students, parents and teachers