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.
Remove these ads by
Signing UpStep 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:
link:
http://davebodnar.com/railway/Pulsed_IR_Article/
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:
http://jeelabs.net/projects/hardware/wiki/JeeNode
Functions left
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);
poll();
done();
and we need some globals:
uint8_t slot, gap, buf [40];
char fill;
uint32_t prev;
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:
http//:www.contrechoc.com/instructables/infra_red_arduino_code.pde
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:
WProgram.h
stdint.h
avr/pgmspace.h
util/atomic.h
Otherwise you get errors on ATOMIC STATE etc.
(In this sketch the fill is still a char.)
Checking
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).
For instance:
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.








































Visit Our Store »
Go Pro Today »




However, as popular as 38kHz has become, many I/R remotes operate at other frequencies. Carriers of 32.7k, 35.5k, 37.5k, 39.2k, 56.0k (even as crazy-high as 455.0kHz!) have been, and sometimes still are being, observed.
Is there a different LDD/pickup ass'y with the bandwidth to handle that kind of spread? With a "wide-open" input device like that, could the system then, somehow, auto-"seek the freq." before reading the code? (This is how the "OmniRemotePro" software works on my ancient Tungsten T PDA, admittedly a bit more machine than the Arduino, even given its silver-whiskered-antique status...)
Also, waddaya bet you could add a mic, modulate voice into an I/R transmitter and make "two-way clothing" that allows you to talk to each other across line-of-sight ranges?
AVR C is of course dedicated for the avr chip, this is a link to basic C scripts for the atmega328 (or other):
https://www.mainframe.cx/~ckuethe/avr-c-tutorial/
the scripts can be uploaded using a programmer.
The dedicated part consists of the many registers and their names.
If you understand this part, you can put this code also in the Arduino scripting window, it works! (Mind the setup and loop seperation.)
The files of the Arduino "hiding" this same C code are in the Arduino folder, hardware, arduino....
You could also write C in Eclipse, Google for links.