Digital Pins (ON/OFF Control)

Anand Ramaswami

Welcome back, Maker!
In this blog, we’re going to learn one of the most important ideas in Arduino:

Digital = ON or OFF.

Once you understand digital pins, you’ll be able to control LEDs, buzzers, motors and read buttons.

What Does “Digital” Mean?

A digital signal has only two possible states:

  • LOW
  • HIGH 

There is no in-between for a digital signal.

So digital systems think in binary:

  • 0 or 1
  • OFF or ON
  • False or True

That’s why digital electronics are the foundation of computers and microcontrollers.

Now that we understand what digital means, let’s connect that idea to the NanoMake Pro board and see where digital pins are actually used.

Digital Pins on the NanoMake Pro

On the NanoMake Pro board, digital pins are used for common parts like:

  • D4 → Buzzer
  • D5 → LED 1 / Motor port 1
  • D6 → LED 2 / Motor port 1
  • D9 → LED 3 / Motor port 2
  • D10 → LED 4 / Motor port 2

A digital pin can do these jobs:

Digital Output

The pin sends voltage out (HIGH or LOW) to control something.

What Is a Digital Output Pin?

A digital output pin is a pin your Arduino controls like a tiny switch.

When you set a pin to:

HIGH

  • The board connects that pin to 5V
  • Current can flow
  • Devices like LEDs or buzzers respond (turn ON)

LOW

  • The board connects that pin to GND (0V)
  • No voltage is delivered
  • The device turns OFF

So, if we want the Arduino to control whether something turns ON or OFF, we need a command that tells the pin what to do. That command is digitalWrite().

The Command: digitalWrite()

digitalWrite() is the Arduino command that tells a digital pin to turn:

  • HIGH (ON)
  • LOW (OFF)

Syntax:

digitalWrite(pin, value);

Parameters:

  • pin → the pin number (like 5, 6, 9, 4, etc.)
  • value → HIGH or LOW

Returns: nothing.

Before we can use digitalWrite(), though, Arduino needs to know what kind of job the pin will do. That is why we first use pinMode().

The Command: pinMode()

pinMode() is the Arduino command used to set the behavior of a pin. It tells the Arduino whether a pin will act as an INPUT (to read signals from sensors or buttons) or an OUTPUT (to send signals to devices like LEDs or motors).

Syntax:

pinMode(pin, mode);

Parameters:

  • pin → the pin number (like 2, 5, 9, 13, etc.)
  • mode → INPUT, OUTPUT, or INPUT_PULLUP

Returns: nothing.

So first, we use pinMode() to tell Arduino what the pin should do. Then, if it is an output pin, we can use digitalWrite() to control it.

Now that you know what digital pins are, what digital output means, and which commands are used, let’s move to some examples. These projects will help you understand digital pins by using them in real code.

 

Project-1: Turn ON / OFF LED (Digital Output)

This is the most basic Arduino LED project.
We use digital output, which means the pin can only send HIGH (ON) or LOW (OFF).

Code:

void setup() {

  pinMode(9, OUTPUT);   // Set pin 9 as output

}


void loop() {

  digitalWrite(9, HIGH);  // Turn LED ON

  delay(1000);            // Wait for 1 second

  digitalWrite(9, LOW);   // Turn LED OFF

  delay(1000);            // Wait for 1 second

}

In this project, you may notice that we used delay().
Before moving further, let’s understand what delay() means, because it is an important command in beginner Arduino programs.

The Command: delay()

delay() is the Arduino command that pauses the program for a specified amount of time. During this time, the Arduino stops executing the next lines of code.

Syntax:

delay(time);

Parameters:

  • time → the amount of time to wait (in milliseconds)

Returns: nothing.

Now that we know what delay() does, let’s connect it back to the code.

Output:

Explanation of the code:

  • pinMode(9, OUTPUT); tells Arduino that pin 9 will control an LED.
  • digitalWrite(9, HIGH); sends voltage to the LED so it turns ON.
  • digitalWrite(9, LOW); stops the voltage so the LED turns OFF.
  • delay(1000); waits for 1 second.

This repeats forever, so the LED keeps turning ON and OFF.

This first project shows the most basic use of digital output. Once you understand this, you can make the LED blink faster, slower, or in different patterns. That leads us naturally to the next example.

 

Project-2: Blinking the LED

In this project, the LED keeps blinking continuously.

Code:

void setup() {

  pinMode(9, OUTPUT);   // LED connected to pin 9

}

void loop() {

  digitalWrite(9, HIGH); // LED ON

  delay(500);             // Wait 0.5 seconds

  digitalWrite(9, LOW);  // LED OFF

  delay(500);             // Wait 0.5 seconds

}

Output:

Explanation:

  • The LED turns ON for half a second.
  • Then it turns OFF for half a second.
  • This creates a blinking effect.

Blinking LEDs are commonly used in status indicators, alerts, and signals.

So far, we have controlled only one LED. But digital output becomes even more interesting when we use it with more than one LED. Let’s move to that next.

 

Project-3: Blinking Multiple LEDs

Here we control more than one LED using digital output.

Code:

void setup() {

  pinMode(5, OUTPUT);

  pinMode(6, OUTPUT);

}


void loop() {

  digitalWrite(5, HIGH); // LED 1 ON

  digitalWrite(6, LOW);  // LED 2 OFF

  delay(1000);


  digitalWrite(5, LOW);  // LED 1 OFF

  digitalWrite(6, HIGH); // LED 2 ON

  delay(1000);

}

Output:

Explanation:

  • Two LEDs are connected to pin 5 and pin 6.
  • When LED 1 turns ON, LED 2 stays OFF.
  • Then LED 1 turns OFF and LED 2 turns ON.
  • This creates an alternating blinking pattern.

This type of control is used in signals, indicators, and light patterns.

Now we can see that digital output is not only for turning one device ON and OFF. It can also help us create patterns. To understand that even better, let’s look at a more interesting LED sequence.

 

Project-4: LED Wave Pattern (Digital Output)

In this project, LEDs turn ON one by one and then come back in reverse order.
This creates a wave-like light pattern. It looks like the light is moving forward and then coming back, just like a wave.

Setup

void setup() {

  pinMode(5, OUTPUT);

  pinMode(6, OUTPUT);

  pinMode(9, OUTPUT);

  pinMode(10, OUTPUT);

}

Explanation

  • pinMode(5, OUTPUT); → LED on pin 5 will send voltage out.
  • pinMode(6, OUTPUT); → LED on pin 6 will send voltage out.
  • pinMode(9, OUTPUT); → LED on pin 9 will send voltage out.
  • pinMode(10, OUTPUT); → LED on pin 10 will send voltage out.

These pins will control the LEDs.

Loop

void loop() {

  digitalWrite(5, HIGH);

  delay(200);

  digitalWrite(5, LOW);


  digitalWrite(6, HIGH);

  delay(200);

  digitalWrite(6, LOW);


  digitalWrite(9, HIGH);

  delay(200);

  digitalWrite(9, LOW);


  digitalWrite(10, HIGH);

  delay(200);

  digitalWrite(10, LOW);


  digitalWrite(9, HIGH);

  delay(200);

  digitalWrite(9, LOW);


  digitalWrite(6, HIGH);

  delay(200);

  digitalWrite(6, LOW);

}

Output:

Explanation:

  • LED on pin 5 turns ON, then OFF.
  • LED on pin 6 turns ON, then OFF.
  • LED on pin 9 turns ON, then OFF.
  • LED on pin 10 turns ON, then OFF.

After reaching the last LED, the pattern moves backward:

  • LED on pin 9 turns ON, then OFF.
  • LED on pin 6 turns ON, then OFF.

This creates a wave effect where the light moves forward and then backward.

This project is a nice example of how digital output can create more than simple blinking. It can make the board look active, interactive, and fun.

Why This Is Cool:

This kind of pattern is useful for:

  • decorative lighting
  • learning LED sequencing
  • understanding program flow
  • building fun beginner robot projects

After seeing these examples, it becomes easier to understand where digital output is used in real electronics projects.

Real-Life Examples of Digital Output

Digital output is used in many beginner electronics projects, such as:

  • turning an LED ON and OFF
  • making a buzzer beep
  • controlling a relay
  • triggering a small module
  • giving signals in a robot

If a device only needs simple ON/OFF control, digital output is usually the right choice.

Once you understand how to use HIGH and LOW, you can build many exciting beginner projects.
You are no longer just reading code ,you are making the board interact with the real world.

That is where electronics start becoming fun.

Keep experimenting, keep building, and keep making.

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.