Infra Red Vest Code


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.)

Remove these adsRemove these ads by Signing Up
AlThorpe2 years ago
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

Get More Out of Instructables

Already have an Account?


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!