This vest shows the infrared codes which are bombarding us all the time in rooms. Infrared is used for the remote controls of television sets, computers, video/dvd players, lamps, robots, and so on. The codes are sent at a frequency of 38 kHz.
The signal itself is sent within the light spectrum range of infra red which is invisible for the human eye, but visible when you point your digital camera on the led. Cameras but also insects (for instance) do have infra red vision.
Some remote controls are sending several codes, or are in regular contact with the device they are supposed to control.
The codes are just a sequence of 1's and 0's. All the codes are different, some have an elaborate signature at the beginning and the different buttons on the remote control make different endings.
When a infra red code is detected by the vest the led's light up. One shoulder is showing the reception, the other shoulder is showing the code.
The vest provide enough space for a large collection of remote controls as a belt and in the pocket at the right hand side, where also the chips and the batteries are hidden.
Step 1: Test Arduino Code
The problem is, we have the code for the flexible LED strip in C ...
see my instructable: http://www.instructables.com/id/Making-a-flexible-ring-of-LEDs/
... but we have the infra red library in Arduino code! Do you think these two bits of code can be merged like that? Wrong!
So first get our infra red sketch working on the Arduino.
In the Jeelabs.org store you can buy a infra red plug and in the library Ports of Jeelabs.org there are examples getting the infra red signal.
These is all very convenient, and it works, but...you have not learnt too much! Certainly not how to port it, merge it with other code.
Infra red devices:
You can also, and rather easily, make the receiver and sender yourself. The special IR diode with frequency controller (only receiving the 38 kHz) is about 1.60 euro at conrad.nl and works right away.
The sender needs a 555 timer to send at 38kHz, and you can find the schematics everywhere, at jeelabs.org, but also here:
Porting the code
If you start exploring the infra red part of Ports the first thing you notice is the difference in digitalWrite and digiWrite of Jeelabs. Since my goal is AVR C code in a AVR project I have to rewrite the digiWrites in digitalWrites (and then to C in the next step). This is not too difficult, because you can find an easy conversion table at the Jeelabs site:
Ports is in C++ and we go to Arduino C, so the c++ objects have to be rewritten. This is also easy, no real object structure is used. So we get a Arduino script with the functions from the library, not using the library Ports anymore.
These are the functions left for infrared use:
configure(uint8_t slot4, uint8_t gap256);
and we need some globals:
uint8_t slot, gap, buf ;
Now this char fill variable works in Arduino code, but not in AVR Gcc! It has to be changed in an int, since it uses negative values...
If you have the infra red diode you can test with the following sketch:
where PC3, or analog 3, or digital 17 is the input pin for the infra red diode device (used here as a digital PIN).
I have used pin 6 and 7 to power my liquid display for testing.
You can see I included libraries used by the functions from the Ports lib:
Otherwise you get errors on ATOMIC STATE etc.
(In this sketch the fill is still a char.)
Checking the infra red code working from the Arduino is easy: just use the serial window.
Checking from avr gcc is not so straightforward, so already in the Arduino Code phase I added a Liquid Crystal to check if the Serial output was also appearing on the small Liquid Crustal screen. (This Liquid Crystal is attached to a Attiny2313.)
Hidden Arduino files
Arduino code is convenient if you compare it to AVR C. This making it easy is the big success of the Arduino! But going one small step further like me, and you have to understand a bit how this success was made possible.
So behind the ARduino srcipt is lain C.
Ports uses also the special Arduino files (hidden in the arduino folders and linked with an invisible makefile).
In AVR Gcc i cannot use digitalWrite etc unless either I make my own function or use the Arduino files. Likewise for the function micro's.