Embedded systems & interfaces
GPIO, pull-ups & logic compatibility
A software pin needs an electrical plan.
A microcontroller combines a processor, memory and peripherals. GPIO pins can be inputs, outputs or peripheral signals, with device-specific limits. An undriven input can float. A pull-up or pull-down supplies a weak default state while allowing a switch or open-drain output to override it. Confirm input thresholds, maximum voltages and both per-pin and total current limits before connecting devices.
Timers, interrupts & PWM
Let hardware keep time while software does something else.
Polling repeatedly checks a condition; an interrupt requests attention when an event occurs. Keep interrupt handlers short and coordinate shared data carefully. Hardware timers count clock ticks and can generate repeatable events, capture input timing or produce PWM. A non-blocking state machine often keeps software responsive better than long delay calls. PWM changes pulse width, not necessarily the pulse height or repetition frequency.
UART, I²C & SPI
Agree on both the wires and the conversation.
UART commonly sends asynchronous framed data with agreed baud and format. I²C shares clock and data, uses addresses and usually open-drain lines with pull-ups. SPI uses a clock, data directions and chip selection, but framing and mode still depend on the device. These are not interchangeable electrical interfaces. RS-232 and RS-485 define different physical signaling from a bare microcontroller UART.
One press, one event
Teach a program to wait for a switch contact to settle.
Mechanical contacts may bounce between open and closed during one press. A software debouncer remembers a candidate state and when it last changed, then accepts it only after it stays unchanged for a chosen interval. Detect a press from the accepted state transition, not every loop iteration. A pull-up or pull-down still provides a defined electrical level.