© Neil Cameron 2019
Neil CameronArduino Appliedhttps://doi.org/10.1007/978-1-4842-3960-5_20

20. Interrupts and Timed Events

Neil Cameron1 
Edinburgh, UK

Interrupts allow the microcontroller to respond to an external signal, such as the change in state of a device, while performing another task. An interrupt pauses the sketch and implements the interrupt service routine (ISR), then the sketch continues from the point that it was interrupted.

There are at least three approaches for scheduling an event to occur after a certain period of time has elapsed. The simplest is the delay() function, which pauses the sketch for the required number of milliseconds. A second approach is to use the millis() function, which returns the number of milliseconds that ...

Get Arduino Applied: Comprehensive Projects for Everyday Electronics now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.