Skip to content
UPEEC

GPIO

General-purpose input/output pins: configure them as inputs or outputs, with pull-ups and drive limits.

Beginner
Comments 0

Each pin is configured by registers: direction (input/output), output value, pull-up/down, and sometimes open-drain mode and speed.

pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
pinMode(2, INPUT_PULLUP);
int pressed = digitalRead(2) == LOW;

Respect the current limits (ATmega328P: 20 mA recommended, 40 mA absolute max per pin; many 3.3 V chips allow far less). Drive motors, relays and LED strips through transistors.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.