Periodic Events

Accessors can use the setInterval() function to schedule periodic events. setInterval() takes a callback function and milliseconds as arguments. Any further arguments will be passed to the callback function.

Here, we'll create a camera that takes a snapshot every five seconds. Periodic events can continue indefinitely, or can be canceled by saving the returned handle and invoking clearInterval(handle).

Click 'react to inputs'. The camera should start taking snapshots every five seconds, stopping after one minute.

Next, make duration and interval parameters to control the camera.