Digital pins on Arduino are the basic building blocks of every project. They allow you to turn LEDs on and off, read buttons, control relays, motors, or communicate with other devices. Understanding digital pins is the first step toward mastering electronics.
1. What Is a Digital Pin?
A digital pin is an input or output that can represent only two values:
- HIGH – 5V (or 3.3V on some boards)
- LOW – 0V
This means a digital pin works like a switch: on or off.
2. Digital Output (OUTPUT)
When a pin is set as an output, Arduino sends voltage to that pin. The most common example is turning on an LED.
pinMode(13, OUTPUT); digitalWrite(13, HIGH); // turn LED on digitalWrite(13, LOW); // turn LED off
Digital output is used for:
- LEDs
- relays
- motors (via driver)
- buzzers
- signal lights
3. Digital Input (INPUT)
When a pin is set as an input, Arduino reads the state of that pin. The most common example is reading a button.
pinMode(2, INPUT);
int state = digitalRead(2);
if (state == HIGH) {
// button is pressed
}
Digital input is used for:
- buttons
- switches
- digital sensors
- PIR motion detectors
4. Internal Pull-Up Resistor
When reading buttons, the internal pull-up resistor is often used to stabilize the signal and prevent floating values.
pinMode(2, INPUT_PULLUP);
In this mode, the button is pressed when the state is LOW.
Summary
| Concept | Description |
|---|---|
| HIGH / LOW | A digital pin has only two values |
| OUTPUT | Arduino sends voltage to the pin |
| INPUT | Arduino reads the pin state |
| INPUT_PULLUP | Stabilizes button input signals |
Digital pins are the foundation of every Arduino project. Once you master them, you can move on to more advanced systems such as PWM, sensor communication, and smart automation projects.