This instructable is about the code and the devices used for the infra red vest. The sewing you have to invent yourself!

 

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 adsRemove these ads by Signing Up

Step 1: Test Arduino Code

ir8.jpg
ir7.jpg
The challenge is to get all the necessary code on a stand alone atmega328 chip using AVR Gcc.
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.



Dr. dB says: Jan 31, 2012. 1:28 PM
What a cool project! (Or a warm one, depending on the garment you chose to use!) It certainly could make laser-tag a lot more WOW, visually speaking...

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?

AlThorpe says: Jan 20, 2012. 12:38 PM
Like the project and the links for Arduino / Jeelabs related info, thanks for posting. Can you explain how you get at the C equivalent of arduino code. I also thought this would be a good route on learning C but could not see how to get at the raw files? Thanks, Al
contrechoc (author) says: Jan 21, 2012. 8:36 AM
C is best learnt in one of the many c tutorials on the internet.
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.
bumsugger says: Jan 19, 2012. 2:59 PM
ER,whaddoes it do? Have I missed something here.....................??
contrechoc (author) says: Jan 21, 2012. 8:29 AM
the vest reacts to remote controls sending infrared code at 38 kHz. The Led's show this code....
Kasm279 says: Jan 19, 2012. 3:24 PM
I like the old Apple remote you tested with- classic!
XOIIO says: Jan 17, 2012. 11:04 AM
I really hope you aren't one of those people who think thse signals are "dangerous" and made it to show people how many there are around.
contrechoc (author) says: Jan 18, 2012. 8:55 AM
Not at all! I use also RF in clothing (sending poetry around, or recycling received messages and sending greens words from the reassembled letters back). The difference for me is that infra red "feels soft" because it is always contained in a room, the living space, while RF penetrates walls, buildings etc. The "softness" of infra red is (for me personally) related to the softness of fabric. That's why it suits me.
rkeyzer says: Jan 15, 2012. 7:56 PM
It looks like something you would see in startrek
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!