Introduction
Embedded devices often need to notice events such as a button press, a timer reaching its limit, or a sensor producing new data. Two common ways to do this are polling and interrupts. Polling checks for events repeatedly; an interrupt asks the processor to respond when an event occurs. The difference affects how a device uses its time, how quickly it reacts, and how complex its software becomes.
The basic difference
An embedded system is a computer built into a larger product, such as a thermostat, appliance, vehicle component, or measuring instrument. Its processor runs software that interacts with hardware: sensors, buttons, displays, motors, communication ports, and other components. The software needs a way to find out when those components need attention.
With polling, the processor checks a device or status flag at intervals. It might repeatedly ask, “Has the button been pressed?” or “Is there new data?” If the answer is no, it moves on and checks again later. Polling is like looking at a clock every few moments to see whether it is time for an appointment.
With an interrupt, hardware or software signals the processor when a particular event occurs. The processor temporarily pauses its current work, runs a short section of code to respond, and then usually returns to what it was doing. This is more like an alarm that sounds when the appointment time arrives.
Neither method is automatically better. Polling can be straightforward and predictable, while interrupts can make a system more responsive and avoid repeated checks. The right choice depends on the event rate, timing requirements, available processing time, hardware, and how much complexity the design can manage.
How polling works
A polling program follows a repeated routine. It checks one or more inputs, handles any conditions it finds, and then repeats the checks. In a simple device, this routine may run continuously. In another design, the processor may wait for a set interval between checks.
For example, imagine a small control panel with a button and a temperature sensor. The software could check the button, read the sensor, update a display if needed, and then start the cycle again. If the button is pressed just after its check, the software may not notice until the next time it reaches that check.
The time between checks matters. Checking frequently can reduce the wait before an event is noticed, but it also uses more processor time and may consume more energy. Checking less often leaves more time for other work or for the processor to rest, but an event may go unnoticed for longer. A polling interval is therefore a design choice, not just a programming detail.
Polling is especially easy to understand when there are only a few inputs and the device can tolerate a small response delay. It can also make the order of operations clear: the software checks each item in a known sequence. However, as the number of devices grows, the repeated checks can take up a larger share of the processor’s time.
How interrupts work
An interrupt begins when a component signals that something needs attention. A timer can generate an interrupt at a scheduled moment. A communication interface might generate one when a byte arrives. A sensor or external pin can signal a change, depending on the hardware and its configuration.
The processor responds by pausing its current instruction flow and saving enough information to resume later. It then runs an interrupt service routine, often shortened to ISR. The routine deals with the immediate event or records information so the main program can handle it. When the interrupt work is finished, the processor returns to the interrupted task.
Consider a device receiving messages over a communication link. Instead of repeatedly checking whether a message has arrived, the interface can interrupt the processor when data is available. The ISR might read the data or place it in a buffer, a temporary storage area. The main program can then process the message when it is ready.
An interrupt does not mean that the processor handles an event with no delay. It takes time to recognize the signal, pause the current work, and run the response code. Other interrupts may also be in progress, or the software may temporarily prevent certain interrupts from being handled. The actual response time depends on the processor, configuration, and software design.
Key differences between interrupts and polling
When the processor checks for an event
Polling makes the software check at times chosen by its routine. An interrupt is triggered by an event or condition recognized by the hardware or system. Polling is therefore initiated by the program’s repeated checks; an interrupt is initiated by a signal that requests attention.
Processor time and energy
Repeated polling can use processor time even when nothing has changed. That may be acceptable if the processor has little else to do, but frequent checks can compete with other tasks. Interrupts can avoid those checks when events are occasional, allowing the processor to spend time on other work or, in some designs, enter a low-power state.
Interrupts do not guarantee lower energy use in every system. Frequent events can repeatedly wake the processor, and the interrupt-handling work itself has a cost. A device that must examine inputs constantly may be simpler or more efficient with polling, particularly if those checks can be combined with work the processor already performs.
Response time
Polling can only notice an event when the relevant check occurs. If checks are far apart, the wait can be longer; if they are frequent, response time can improve at the cost of additional checking. An interrupt can prompt a response soon after the event is recognized, which is useful when timing matters.
However, interrupt response time is not always perfectly immediate or identical from one event to the next. The processor may be completing another operation, handling a higher-priority interrupt, or temporarily blocking interrupts. Designers must consider these conditions when predictable timing is important.
Program structure and complexity
A polling loop can be easy to follow because the checks and actions appear in a visible sequence. Interrupt-based programs can be harder to reason about: an ISR may run between two lines of the main program, and shared information may change unexpectedly from the viewpoint of that program.
This does not make interrupts inherently unsafe. It means that the software needs clear rules for which code can access shared data, how events are recorded, and how work is divided between the ISR and the main program. Good design keeps interrupt routines short and avoids doing lengthy, non-urgent tasks inside them.
Common examples in embedded electronics
Button input: A device can poll a button at regular intervals, or use a pin interrupt to notice a change. For a human-operated control, a short delay is often acceptable, so either approach may work. Mechanical buttons can produce several rapid electrical changes during one press, a behavior called bounce. Software may need to filter these changes, whether it uses polling or interrupts.
Timers: A timer can be polled by checking whether it has reached a target value, or it can generate an interrupt at that point. An interrupt is useful when the processor has other work to do between timer events. Polling may be convenient when the program already checks the timer as part of its normal routine.
Communication: A device can repeatedly check a communication interface for incoming data. Alternatively, the interface can interrupt the processor when data arrives or when a buffer needs attention. For a stream of frequent data, interrupts may need to be coordinated carefully so that the software can keep up and avoid losing information.
Sensor readings: A processor might poll a sensor at a chosen rate, which gives the software direct control over when readings are taken. Some sensors can instead signal when a reading is ready or when a measured value crosses a configured threshold. The available options depend on the sensor and its connection to the processor.
Interrupts, priorities, and shared data
Many processors support different interrupt priorities. A higher-priority event may be allowed to interrupt a lower-priority routine, while a lower-priority event waits. Priorities can help time-sensitive work receive attention, but they also add design decisions: an overly long or poorly prioritized routine may delay other events.
Interrupt routines usually need to be brief because the processor may be unable to do other work while they run, especially if further interrupts are restricted. A common pattern is to handle only what must happen immediately, then set a flag or place data in a buffer for the main program to process. This separates quick event capture from more time-consuming work.
When both an ISR and the main program use the same information, the design must account for the possibility that one changes it while the other is reading it. Embedded programming languages and processors provide different ways to manage this, and the appropriate method depends on the data and hardware. The general principle is to make shared access deliberate rather than assuming that operations cannot overlap.
Can polling and interrupts be combined?
Yes. Many embedded systems use both. A processor might poll routine status information while relying on interrupts for urgent events. It might also use an interrupt to record that a device needs attention, then let the main loop poll or process a queue of pending tasks.
A hybrid approach can keep the main program organized while avoiding constant checks for events that happen irregularly. For instance, a communication interrupt could store arriving data, while the main loop periodically handles that stored data alongside other tasks. The balance depends on how quickly the data must be processed and how much work the system can perform.
Some systems use polling within a scheduled task structure rather than a single uninterrupted loop. Others rely heavily on interrupts. These are design patterns, not strict categories: a real device may use several methods for different components.
How to choose between polling and interrupts
Start by asking how quickly the system must respond. If a delay of a few checks is acceptable, polling may be sufficient. If an event is rare but needs prompt attention, an interrupt may be a better fit. The required response time should be considered alongside the processor’s workload and the behavior of the connected hardware.
Next, consider how often the event occurs. Frequent events can make repeated polling practical, particularly when checks are already part of the program’s normal work. Irregular events may suit interrupts because the processor need not keep asking whether anything has changed. But a very high event rate can create substantial interrupt work, so the system must be able to handle the incoming activity.
Also consider simplicity, power use, and reliability. A small project with one or two slowly changing inputs may benefit from a clear polling routine. A battery-powered device may benefit from waking only when needed, if its hardware and software support that approach. A system with strict timing requirements may need a carefully measured design, rather than choosing a method based on general rules alone.
Testing matters whichever method is used. Designers need to check how the system behaves when events arrive close together, when several devices request attention, and when processing takes longer than expected. These conditions reveal whether polling intervals, interrupt priorities, buffers, and task handling are appropriate for the device.
Conclusion
Polling repeatedly checks for events, while interrupts signal the processor when an event needs attention. Polling is often simpler and can suit predictable, low-demand tasks; interrupts can improve responsiveness and reduce unnecessary checking for irregular events. Both have trade-offs in timing, processor use, energy, and software complexity. Many embedded devices combine them, choosing the approach that best fits each task.

