Step 2: Re-using Arduino files for micro and the timer

You can get the Arduino functions in AVR gcc if you want to, just copying the parts you need from the Arduino lib inside the Arduino folder. For some reason I keep using the Arduino 018 versions so in the folder, but that does not matter too much.

You can find the files needed in the Arduino folder:

hardware/arduino/cores/arduino (yes two times arduino)
there you find the arduino files, which saves a lot of people learning the C of AVR :-), but at a cost of speed and size.

I needed the micro functions and the interrupt, which I found in wiring.c
I copied: (also copying the variables and defines I needed from wiring.h)

unsigned long millis()
unsigned long micros()

but very important, to get the timer/interrupt started is the:
void init()
There is a lot of code you can skip if you know you use a atmega328.

Then we get this code in two nice files, a source and a header:
(This is a total AVR project you can use for further fun.)

Also included here are, a UART.c and UART.h, for communication with the liquid crystal.

You see I have made the fill an int variable.

Also the analog read is activated for an LDR, and one pin is used to make the other shoulder light up when a signal at 38kHz is received.

initTimers(); is used to start the interrupts, the init() function from wiring.c

In the header file you find the connections with the groups of LED's (flexible LED strips)
//connections to PIN's from the led circle
unsigned char  rows[8] = { 7, 6, 5, 4, 3 , 2, 1, 0 };
unsigned char  cols[8] = { 15, 14, 13, 12, 11, 10, 9, 8 };

The interrupt function is different from the flexible LED strips I used before:

In this function, besides the "Arduino code" I have added my own interruptFie();
This function takes care of the LED block MATRIX activities.

In the setIRPattern(uint8_t count) function you see the matrix for the LED's on the shoulder band.
The 3's indicate the missing LED's form the 64 (I didn't use the full 64 = 8 x 8 LED's in the vest.)

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... <br> <br>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. <br> <br>Is there a different LDD/pickup ass'y with the bandwidth to handle that kind of spread? With a &quot;wide-open&quot; input device like that, could the system then, somehow, auto-&quot;seek the freq.&quot; before reading the code? (This is how the &quot;OmniRemotePro&quot; software works on my ancient Tungsten T PDA, admittedly a bit more machine than the Arduino, even given its silver-whiskered-antique status...) <br> <br>Also, waddaya bet you could add a mic, modulate voice into an I/R transmitter and make &quot;two-way clothing&quot; that allows you to talk to each other across line-of-sight ranges? <br> <br>
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
C is best learnt in one of the many c tutorials on the internet.<br>AVR C is of course dedicated for the avr chip, this is a link to basic C scripts for the atmega328 (or other):<br><br>https://www.mainframe.cx/~ckuethe/avr-c-tutorial/<br><br>the scripts can be uploaded using a programmer.<br>The dedicated part consists of the many registers and their names.<br>If you understand this part, you can put this code also in the Arduino scripting window, it works! (Mind the setup and loop seperation.)<br>The files of the Arduino &quot;hiding&quot; this same C code are in the Arduino folder, hardware, arduino....<br>You could also write C in Eclipse, Google for links.
ER,whaddoes it do? Have I missed something here.....................??
the vest reacts to remote controls sending infrared code at 38 kHz. The Led's show this code....
I like the old Apple remote you tested with- classic!
I really hope you aren't one of those people who think thse signals are &quot;dangerous&quot; and made it to show people how many there are around.
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 &quot;feels soft&quot; because it is always contained in a room, the living space, while RF penetrates walls, buildings etc. The &quot;softness&quot; of infra red is (for me personally) related to the softness of fabric. That's why it suits me.
It looks like something you would see in startrek

About This Instructable


18 favorites


Bio: http://myfablab.wordpress.com/ https://www.smashwords.com/profile/view/beamchoc
More by contrechoc: In your own time! LCD Magic Warming up!
Add instructable to: