I was looking at the Timer1.h and Timer1.cpp code.
I need a PWM routine with 10 bit resolution. Eight bits is not enough.
Here is an example main routine:
/*
- Timer1 library example
- June 2008 | jesse dot tane at gmail dot com
*/
#include "TimerOne.h"
void setup()
{
pinMode(10, OUTPUT);
Timer1.initialize(500000); // initialize timer1, and set a 1/2 second period
Timer1.pwm(9, 512); // setup pwm on pin 9, 50% duty cycle
Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt
}
void callback()
{
digitalWrite(10, digitalRead(10) ^ 1);
}
void loop()
{
// your program here...
}
I see that timer1.h is included, but where does Timer1.cpp ever get included into this? How does the compiler know?
I want to monitor a volt on a pin with analog read. Depending on the value I will lower or raise the duty cycle. Would I do this within a loop and call setPwmDuty(pin, duty) since I would have already setup the pwm parameter?