(NOTE: PJRC HAS SINCE UPDATED THE LIBRARY TO INCLUDE THE LEONARDO)
I have been teaching Physical Computing for Artists with the Arduino Uno for over a year now and this year I decided to move to the Leonardo with the hope that a USB-Midi based core will be finished sometime soon. Its cheaper than the uno and it has a serial port that isn’t busy and best of all it doesn’t reboot every time you talk to it.
I usually introduce background tasks using the Timer1 library since it makes timers manageable for the novice. However the existing Timer1 and Timer3 libraries are not currently avaliable for the leonardo (or any of the 4 32u4 based processors). Fortunately there is a “port” of the library for the Teensy2.0 at http://www.pjrc.com/teensy/arduino_libraries/TimerOne.zip, for some reason the leonardo is missing from the boards supported but no matter the fix is pretty easy and now I can get back to teaching.
diff ~/Downloads/TimerOne/config/known_16bit_timers.h TimerOne/config/known_16bit_timers.h 11,22c11,34 < < // Teensy 2.0 < //< < // Teensy 2.0 < // < #elif defined(__AVR_ATmega32U4__) && defined(CORE_TEENSY) < #define TIMER1_A_PIN 14 < #define TIMER1_B_PIN 15 < #define TIMER1_C_PIN 4 < #define TIMER1_ICP_PIN 22 < #define TIMER1_CLK_PIN 11 < #define TIMER3_A_PIN 9 < #define TIMER3_ICP_PIN 10 < --- > // mega34u4 > // Ehem: it would be nice to figure out the sparkfun micro-pro > // and the adafruit u4 stuff as well. > #elif defined(__AVR_ATmega32U4__) > // Teensy 2.0 > #if defined(CORE_TEENSY) > #define TIMER1_A_PIN 14 > #define TIMER1_B_PIN 15 > #define TIMER1_C_PIN 4 > #define TIMER1_ICP_PIN 22 > #define TIMER1_CLK_PIN 11 > #define TIMER3_A_PIN 9 > #define TIMER3_ICP_PIN 10 > // otherwise assume Leonardo/micro/esplora > #else > #define TIMER1_A_PIN 9 > #define TIMER1_B_PIN 10 > #define TIMER1_C_PIN 11 > #define TIMER1_ICP_PIN 4 > #define TIMER1_CLK_PIN 12 > #define TIMER3_A_PIN 5 > #define TIMER3_ICP_PIN 13 > #endif >