3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Infra Red Vest Code

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

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)

SIGNAL(TIMER0_OVF_vect)
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:
http://http//:www.contrechoc.com/instructables/infra-red.zip
(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:
SIGNAL(TIMER0_OVF_vect)

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





« Previous StepDownload PDFView All StepsNext Step »
1 comment
Jan 20, 2012. 12:38 PMAlThorpe says:
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

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
14
Followers
17
Author:contrechoc
also doing some blogging here: http://myfablab.wordpress.com/