0% found this document useful (0 votes)
133 views

For Arduino Uno Timer Prescalar PDF

This document contains code for setting the PWM frequency on different pins for Arduino boards using ATmega 8, 168 or 328 microcontrollers. It includes code to set the PWM frequency for pins D5/D6 to values between 976.56Hz and 61.04Hz, for pins D9/D10 to values between 490.2Hz and 30.64Hz, and for pins D3/D11 to values between 980.39Hz and 30.64Hz by configuring the clock prescalers for timers 0, 1, and 2.

Uploaded by

iknowwhatudid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views

For Arduino Uno Timer Prescalar PDF

This document contains code for setting the PWM frequency on different pins for Arduino boards using ATmega 8, 168 or 328 microcontrollers. It includes code to set the PWM frequency for pins D5/D6 to values between 976.56Hz and 61.04Hz, for pins D9/D10 to values between 490.2Hz and 30.64Hz, and for pins D3/D11 to values between 980.39Hz and 30.64Hz by configuring the clock prescalers for timers 0, 1, and 2.

Uploaded by

iknowwhatudid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

For Arduino Uno, Nano, Micro Magician, Mini Driver, Lilly Pad and any other board using

ATmega 8, 168
or 328

//---------------------------------------------- Set PWM frequency for D5 & D6 -------------------------------

//TCCR0B = TCCR0B & B11111000 | B00000001; // set timer 0 divisor to


62500.00 Hz

1 for PWM frequency of

//TCCR0B = TCCR0B & B11111000 | B00000010; // set timer 0 divisor to


7812.50 Hz

8 for PWM frequency of

TCCR0B = TCCR0B & B11111000 | B00000011; // set timer 0 divisor to 64 for PWM frequency of
976.56 Hz
//TCCR0B = TCCR0B & B11111000 | B00000100; // set timer 0 divisor to 256 for PWM frequency of
244.14 Hz
//TCCR0B = TCCR0B & B11111000 | B00000101; // set timer 0 divisor to 1024 for PWM frequency of
61.04 Hz

//---------------------------------------------- Set PWM frequency for D9 & D10 ------------------------------

//TCCR1B = TCCR1B & B11111000 | B00000001; // set timer 1 divisor to


31372.55 Hz

1 for PWM frequency of

//TCCR1B = TCCR1B & B11111000 | B00000010; // set timer 1 divisor to


3921.16 Hz

8 for PWM frequency of

TCCR1B = TCCR1B & B11111000 | B00000011; // set timer 1 divisor to 64 for PWM frequency of
490.20 Hz
//TCCR1B = TCCR1B & B11111000 | B00000100; // set timer 1 divisor to 256 for PWM frequency of
122.55 Hz
//TCCR1B = TCCR1B & B11111000 | B00000101; // set timer 1 divisor to 1024 for PWM frequency of
30.64 Hz

//---------------------------------------------- Set PWM frequency for D3 & D11 ------------------------------

//TCCR2B = TCCR2B & B11111000 | B00000001; // set timer 2 divisor to


31372.55 Hz

1 for PWM frequency of

//TCCR2B = TCCR2B & B11111000 | B00000010; // set timer 2 divisor to


3921.16 Hz

8 for PWM frequency of

//TCCR2B = TCCR2B & B11111000 | B00000011; // set timer 2 divisor to 32 for PWM frequency of
980.39 Hz
TCCR2B = TCCR2B & B11111000 | B00000100; // set timer 2 divisor to 64 for PWM frequency of
490.20 Hz
//TCCR2B = TCCR2B & B11111000 | B00000101; // set timer 2 divisor to 128 for PWM frequency of
245.10 Hz
//TCCR2B = TCCR2B & B11111000 | B00000110; // set timer 2 divisor to 256 for PWM frequency of
122.55 Hz
//TCCR2B = TCCR2B & B11111000 | B00000111; // set timer 2 divisor to 1024 for PWM frequency of
30.64 Hz

You might also like