Hello,
I'm wondering if there's an easy way to set the output of the Arduino's frequency to 50Hz. I understand that the output of the PWM pins is around 500Hz? Am I correct? I'm trying to do this to drive a couple servo motors. I also need to vary the duty cycle. I'm not sure if I should be using digitalWrite() or AnalogWrite().
Right now I'm just using this:
void setup()
{
pinMode(10, OUTPUT);
}
void loop()
{
digitalWrite(10, HIGH);
delay(10); // Approximately 10% duty cycle @ 1KHz
digitalWrite(10, LOW);
delay(10);
}
To output my 50Hz square wave. Whenever I try to use pushbuttons to simulate a signal to make the duty cycle change, the duty cycle gets all messed up.
I need to use a 5%, 7.5%, and 10% duty cycle. Any help would be appreciated.
Thank you.