IntermediateTopic 61 of 104Electronics & Embedded

GPIO

Programmable pins used as digital inputs or outputs.

In depth

General-purpose I/O pins configured as input (with pull-up/down) or output (push-pull/open-drain) via registers. Read buttons, drive LEDs, bit-bang protocols. Respect current limits per pin; use transistors for loads. Alternate functions connect peripherals.

Key points

  • Pin multiplexing
  • Debounce
  • Drive strength
Example

Setting a bit in the port output register turns an LED on.

Why it matters

General-purpose I/O pins are the basic link between a microcontroller and the real world, so their configuration decides what a board can do.

Where this is used

  • Driving an LED from a GPIO pin with a series resistor.
  • Reading a push button with an internal pull-up resistor.
  • Toggling a pin to bit-bang a custom protocol.

Frequently asked questions

What is GPIO?

Programmable pins used as digital inputs or outputs.

Why is it important to understand GPIO?

General-purpose I/O pins are the basic link between a microcontroller and the real world, so their configuration decides what a board can do.

What is the difference between push-pull and open-drain outputs?

A push-pull output drives both high and low. An open-drain output only pulls low, so an external pull-up is needed and it allows wired connections.

Why is a GPIO current limit important?

Each pin and port has a maximum current, so driving a motor or a bright LED directly can damage the pin or the chip.

How is GPIO used in practice?

Typical applications include driving an LED from a GPIO pin with a series resistor, reading a push button with an internal pull-up resistor and toggling a pin to bit-bang a custom protocol.

What should I learn before GPIO?

Study "Interrupts" first (topic 60 of 104 in Electronics & Embedded). It covers the groundwork this topic builds on.

What are the key points of GPIO?

Pin multiplexing. Debounce. Drive strength.

Can you give an example of GPIO?

Setting a bit in the port output register turns an LED on.

What comes after GPIO?

The next topic is "Timers and counters", which builds directly on this one.

How difficult is GPIO?

It is classed as Intermediate in Electronics & Embedded (topic 61 of 104). It is an intermediate topic. Work through the beginner topics in Electronics & Embedded first.

Learning path

Want to practise? Open the interactive course for quick checks, quizzes, simulations and progress tracking.

Related topics