I decided to see if I could read the button presses from an Apple Remote.
Button HEX -------------- ----------- Pause/Play 0x77E12047 Menu 0x77E14047 Volume Up 0x77E1D047 Volume Down 0x77E1B047 Rewind 0x77E11047 Fast Forward 0x77E1E047
I wanted to use each key press to do something. I did Pause/Play to stop and start the buzzer, volume up and down to change the tone, rewind to slow down the frequency of tones and fast forward to increase the frequency.
I added in some extra logic and variables to customise various aspects of the application. This is by no means a polished piece.
I got this compile error:
core.a(Tone.cpp.o): In function `__vector_7': /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Tone.cpp:535: multiple definition of `__vector_7' IRremote/IRremote.cpp.o:/Users/andrew/Documents/Arduino/libraries/IRremote/IRremote.cpp:311: first defined here
In order to use
tone() with the IRremote library I had to modify IRremoteInt.h in the
libraries/IRremote folder on to use
IR_USE_TIMER1 on line 66 and commented out
IR_USE_TIMER2. I don’t fully understand this yet, other than there was some sort of conflict going on, but that’s how I got it to work, and that’s the important thing!
So now I have the following:
The code is available on GitHub.
I wired up the buzzer to pin 2 and ground. It doesn’t matter which leg of the buzzer goes to which. With the curved surface of the IR sensor facing toward me, I wired the first leg to pin 11, the second leg to ground and the third to power (5V).
It’s pretty amazing what you can do with a few bucks of electronics with an Arduino and I am starting to feel that less and less things are beyond my grasp, which is a great feeling. I feel I’ve learned a lot already and have made mistakes along the way, but without those mistakes I wouldn’t have learned so much!
I plan on documenting my little projects as I go along with a few more epic, thorough guides like The Absolute Beginner’s Guide to Arduino along my way.
What would you do with an IR sensor and a remote you’ve got kicking about?