Hi, thank you so much for your help, I already solve the problem....now, I'm traying to manipulate the "frequency" value from the Serial monitor...but I can't make it work, here's the code:
PD: Any help, THANKS!!!
/************************** TEC -2013 **************************
Este sketch es una variacion del PWM_lib_example de la biblioteca PWM,
donde se controla la frecuencia desde el monitor serial del IDE,
dando con ello un poco mas de practicidad, y mayor manejo sobre la
frecuencia deseada.
*/
#include <PWM.h>
int brightness = 0; //how bright the LED is.
int fadeAmount = 5; //how many points to fade the LED by
void setup()
{
//Inicializa todos los timers del Arduino, excepto el 0, para mantener las funciones de tiempo del micro
Serial.begin(9600);
InitTimersSafe();
}
void loop()
{
int32_t frequency;
if (Serial.available())
{
frequency = Serial.read();
SetPinFrequency(led, frequency);
}
pwmWrite(led, brightness);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
delay(30);
}