awesome library !
I have a question here.
my mega 2560 is connect to tlc5940 pwm chip. and it use timer 1 and timer 2.
according to the datasheet of mega 2560 pin 7 is using timer 4.
so i using a led and try to connect pin 7 and it is working (can see the different between 20hz to 20000hz while it is 20 hz the led dim and blinking. with 20000Hz led dim without blinking). but i want to know is the pin 7 still using timer 4? after i change the pin from default pin to pin 7.
#include <PWM.h>
//use pin 11 on the Mega instead, otherwise there is a frequency cap at 31 Hz
int led = 7; // the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
int32_t frequency = 20000; //frequency (in Hz)
void setup()
{
//initialize all timers except for 0, to save time keeping functions
InitTimersSafe();
//sets the frequency for the specified pin
bool success = SetPinFrequencySafe(led, frequency);
//if the pin frequency was set successfully, pin 13 turn on
if(success) {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
}
void loop()
{
//use this functions instead of analogWrite on 'initialized' pins
pwmWrite(led, brightness);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
delay(30);
}