interrupt for arduino

For those whose application is time critical, you might want to use a time interrupt. This sample code, courtesy of Mike Weller, reads analog in port 0, and returns the reading, at the given interval you pass to OCR1A.

Arduino Sketch: testInterrupt

Let me know if you have questions.

Arduino delay function uses timer0 on the chip, and servo.h uses timer1 , (and PWM timer2??)
I’m using servo lib in Arduino 0018 , so there is a conflict with the previous code, which also utilizes timer1.

One solution is to use ServoTimer2 library available here

The other is to use the 8-bit timer0 in on atmega chip, as implemented below:
Arduino Sketch: InterruptTimer0


~ by cheng on April 23, 2010.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: