I want to create a drumkit that transmits MIDI signals wirelessly, to some MIDI processing device, say, a Mac or an iPhone. Arduinos are powerful and easy enough to get started with, but I want my project to be more portable and task specific, so I decide to shrink it down to an attiny84 powered board.
As a start-with-Arduino electronic enthusiast, I don’t have much coding experience. I tried to write pure C code and compile it with Makefile, but to no avail. Then I put my eyes on Arduino IDE, leaving optimisation and such stuff for future consideration. In order to have any success, I have to:
- Install ATtiny support within Arduino IDE because it doesn’t have that built-in natively, following this tutorial;
- Install NRF24L01 library.
That seems like a breeze, but when I connected everything as NRF24L01 library suggests, and burned some test sketch to the Attiny84 board, nothing happened. Oops… I had no idea what failed or where to debug. I googled around for quite some time, and after some frustration and impatience, I found this ATtiny84 Pin Issue #236. Finally I got the problem: incompatible pin map in the ATtiny support library and NRF24L01 library.
The issue page basically provides two methods: 1) switch to another arduino-tiny support library hosted on google, or 2) edit pin definitions in RF24.cpp of the NRF24L01 library. Method 1) does not work for me. Because I want my project to have as low latency as possible, I chose an external crystal oscillator running at 20MHz, which is the maximum frequency Attiny84 supports, but the jeelabs’ arduino-tiny does not have that option. So I stick with damellis version, and change a few lines of RF24.cpp to
# define DI 6 // PA6
# define DO 5 // PA5
# define USCK 4 // PA4
# define SS 7 // PA7
To test if it works, I have this setup:
-> An Attiny84(damellis’ library compatible pinout) board as an RF24 transmitter, running this sketch,
-> An Arduino UNO turned into an MIDI device as an RF24 receiver, connected to a Mac with a USB cable, running this sketch,
-> A Mac running GarageBand.
LED blinks. Voila!