The flags set in the ISR provide a consistent and easy-to-read way to handle events, and complex polling is not
To keep the main loop simple to read, I’ve dedicated
separate functions to handling the processing around the
button press and the receipt of data over the UART.
So, go ahead. Download the code, compile it, upload
it to your breadboard project, and dig into its workings.
Make changes, tweak, and modify it, and, of course,
please continue to share what you’ve achieved.
This month’s article should have given you the
foundation to start experimenting with other types of
interrupts. If you’re looking for inspiration, why not try to
“upgrade” last month’s thermostat to use interrupts? The
UART interrupts should be straightforward, but you’ll need
to spend some time in the datasheet to write one for the
Next month, we’re going to spend some time working
on the I2C protocol. This will allow us to start adding
additional modules to our projects: real-time clocks,
EEPROM modules, humidity sensors, and a host of others.
Until then, learn to enjoy interruptions! NV
July 2015 33
Figure 9: The Interrupt Vector section of
Atmel illustrates the