Sub topic 1
What the board does and what a digital pin is
Prerequisites
This chapter assumes that you know what a program and a variable are. You should also recognize voltage, current, and resistance at an introductory level. You need an Arduino-compatible board, a USB cable, and the Arduino IDE installed.
The board is a small computer
An Arduino board combines a microcontroller with the connections needed to use it. A microcontroller is a small computer that runs one program repeatedly. The program is called a sketch in Arduino terminology.
The board usually includes:
- A microcontroller, which executes your sketch.
- Digital pins, which connect the program to external circuits.
- Power pins, such as
5V,3.3V, andGND. - A USB connection for power, programming, and often serial communication.
- A reset circuit and a clock that help the microcontroller start and run reliably.
The microcontroller does not directly understand an LED, switch, or motor. It only measures and produces electrical signals at its pins. Your circuit gives those signals a physical result.
For example, a sketch can tell a pin to produce a high logic level. An LED connected correctly to that pin may light. The board is controlling a voltage at the pin; it is not sending a command named “light the LED.”
What a digital pin means
A digital pin is a programmable electrical connection with two main logic states:
LOW, which represents a voltage near the board's ground level.HIGH, which represents a voltage near the board's operating voltage.
A pin can usually work in one of two directions:
- As an input, it measures whether an external signal is low or high.
- As an output, it drives the pin low or high.
The exact voltages depend on the board. A classic Arduino Uno operates its digital logic at 5 V. Many newer boards use 3.3 V. A HIGH signal therefore does not always mean exactly the same voltage on every Arduino-compatible board.
| Pin mode | Direction | Typical use |
|---|---|---|
| Input | Circuit to board | Read a switch or sensor |
| Output | Board to circuit | Control an LED or logic input |
| Input with pull-up | Circuit to board with an internal resistor | Read a switch without an external pull-up resistor |
Digital signals are different from continuously measured values. A digital input normally answers a yes-or-no question: is the signal low or high? A separate analog input can measure a range of voltages. Some boards support additional features, such as pulse-width modulation, on selected digital pins. Those features still depend on the board's hardware.
A pin needs a reference
A voltage is measured relative to another point. On an Arduino circuit, that reference is normally GND, or ground. If an external circuit uses a board pin but does not share the board's ground, the signal may have no reliable meaning.
This simplified view shows the relationship between the program, the microcontroller, and a digital pin:
A digital pin is not an isolated power supply. It has limits on the current it can source or sink. Source means current flows out of the pin. Sink means current flows into the pin while the pin is low. Exceeding the board's limits can damage the microcontroller, even if the circuit appears to work briefly.
Do not connect a motor, relay coil, or other high-current load directly to a digital pin. Those loads need a driver circuit, such as a transistor and often a protection diode. An LED also needs a current-limiting resistor, which the later circuit chapter will calculate.
Common pin mistakes
A pin configured as an input can appear to change randomly when nothing is connected. This condition is called a floating input. The pin is picking up electrical noise instead of reading a defined signal. Use an external resistor or the board's internal pull-up feature to give the input a stable default state.
Also check the pin numbering. The number printed beside a header is the microcontroller pin identifier used by the sketch. It may not match a connector position or an analog channel name. Board documentation is the authority when labels differ.
Exercise
An Arduino Uno and a 3.3 V Arduino-compatible board both set a digital pin to HIGH. What important electrical difference should you expect, and what reference does each signal need?
Show answer
The Uno normally produces a voltage near 5 V, while the 3.3 V board normally produces a voltage near 3.3 V. In both cases, the receiving circuit needs a shared ground reference.