Digital Outputs

  • Pins: On an Arduino Uno, the digital pins are labeled 0 to 13.
  • Modes:
    • pinMode(pin, OUTPUT) → configures the pin for output
    • digitalWrite(pin, HIGH) → sets pin to high voltage
    • digitalWrite(pin, LOW) → sets pin to low (ground)

The maximum output current an Arduino’s digital pin can supply is 40mA (or 20mA continuous current). You cannot use it to drive more than two 20mA LEDs in parallel. It’s a 5V output. Total current for the chipset shall not exceed 200mA, i.e., driving 10 single-color LEDs @ 20mA.

There is no problem driving relay boards (such as from MPJA) directly from digital outputs.  They draw unmeasurable amps on the control signal.

These outputs are push-pull — meaning they can both source and sink current.

You can simulate open-drain behavior by setting the pin to INPUT instead of LOW — useful for I²C and shared lines. An open-drain output is a type of digital output that can pull a line LOW, but not drive it HIGH. This can be useful for a circuit where you potentially want to pull a signal low from multiple pins or multiple devices. If all pins/devices are set up w/ open-drains, this ensures that they can’t “fight” each other no matter what combination of states exist.

Since open drains cannot provide power, a pull-up resistor is used to keep voltage high (to any safe value, useful for controlling 12V devices from a 5V Uno, for example) unless an open drain pulls it low (drains it). When the output is active (on), it connects to GND (pulls low). When inactive (off), it becomes high-impedance (like it’s disconnected). An Uno can sink up to 40mA, but 20mA is a safer limit. These values are not always the same as the source current limits, but in the case of the Uno, they happen to be.