Project: Electronics Bash - #18- Timers


To this point, we've been handling all of the timing and timekeeping in our Arduino programs by hand. If the-next-thing needs to happen at a specific time, or a specific number of milliseconds from now, we've been tracking all that with variables and millis() statements and so on. What if there wa a way for that all to be taken care of in the background, automatically? And what if it was something we'd been doing all along without our knowing it?

Topics Include:

  • Timers in the ATmega328
  • Timer Interrupts and Configuration
  • Timers and built-in Functions (AnalogWrite, Tone, Millis, Delay, Servo)
  • Using timers to build new code

Code

Print Timer

Click here to view code on Github

Print Timer Interrupts

Click here to view code on Github

Blink Interrupts

Click here to view code on Github

Adjustable Speed Blink

Click here to view code on Github
The following code will make use of the above circuit diagram

Tone Interrupts

Click here to view code on Github

Tone Interrupts - Serial

Click here to view code on Github

Tone List

Click here to view code on Github

Pitches.h

Click here to view code on Github
The following code will make use of the above circuit diagram

SnakeMusic.ino

Click here to view code on Github