Frequency changing of pwm pins of arduino uno

hii.
I am trying to change in Arduino Uno the PWM frequency in pin 3 to 2HZ and I don't know what is the correct command which does that which resemble this conversation in the next command line:
TCCR2B = TCCR2B & B11111000 | B00000001; // for PWM frequency of 31372.55 Hz
thank you

Impossible.
The minimum PWM frequency for pin 3 Arduino Uno - 30 Hz

For 2 Hz use software PWM.

.... about 61
If you take the phase correct PWM, you can have a frequency about 30 Hz.
It is a lowest possible value, as far I know

@shirazhill note, 2Hz is possible only with 16 bit timer. UNO has only one such, the Timer1 and corresponding pins are D9 and D10. pin D3 lowest possible PWM frequence is ~30Hz.

2 Likes

I used some 270 Ohm load resistor I think. Note that that tops the load of and I2C LCD and a NEO6-M GPS.

Here's the code I got from helpers:

  //1Hz 90% dutycycle
  pinMode(9, OUTPUT);                               // Set digital pin 9 (D9) to an output
  TCCR1A = _BV(COM1A1) | _BV(COM1A0) | _BV(WGM11);  // Enable the PWM output OC1A on digital pins 9 and invert output
  TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS12);     // Set fast PWM and prescaler of 256 on timer 1
  ICR1 = 62499;                                     // Set the PWM frequency to 1Hz: 16MHz/(256 * 1Hz) - 1 = 62499
  OCR1A = 6249;                                     // Set the duty-cycle to 10%: 62499 / 10 = 6249

  pinMode(10, OUTPUT);                               // 1 Hz pulse output on digital pin 9 (D9)
  pinMode(13, OUTPUT); digitalWrite(13, LOW);// Make board LED go off
  delay(10);//allow pwm timers to start

for 2 Hz

ICR1 = 31249;
1 Like

10 posts were split to a new topic: Two pwm outputs with the same frequency

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.