hello, I need to vary the frequency and duty cycle in a pwm output using two buttons one to vary the frequency and another to vary the duty cycle, I am using a mega arduino 2560, searching here in the forum I found a similar topic where the following code:
#include <PWM.h>
int outputPin = 11;
//For testing
int freqInput = 100; //10-10000 Hz (I wanted that range only)
int dutyCycleInput = 70; //1-65535
void setup()
{
InitTimersSafe();
}
void loop()
{
//Get inputs from either serial or through pot
//So we have Frequency and Duty cycle in variables 'freqInput' & 'dutyCycleInput' respectively in int
SetPinFrequencySafe(outputPin, freqInput );
pwmWriteHR(outputPin, dutyCycleInput );
}
My question is how to add the buttons to vary both frequency and duty cycle in a single output? thanks