#Include #Include : Programmer's Notepad - Main.c
#Include #Include : Programmer's Notepad - Main.c
//***********///
#include <avr/io.h>
#include <util/delay.h>
void InitPWM()
()
{
/*
TCCR0 - Timer Counter Control Register (TIMER0)
----------------------------------------------BITS DESCRIPTION
NO:
NAME
DESCRIPTION
-------------------------BIT 7 : FOC0
Force Output Compare [Not used in this example]
BIT 6 : WGM00 Wave form generartion mode [SET to 1]
BIT 5 : COM01 Compare Output Mode
[SET to 1]
BIT 4 : COM00 Compare Output Mode
[SET to 0]
BIT
BIT
BIT
BIT
3
2
1
0
:
:
:
:
WGM01
CS02
CS01
CS00
}
/******************************************************************
Sets the duty cycle of output.
Arguments
--------duty: Between 0 - 255
0= 0%
255= 100%
The Function sets the duty cycle of pwm output generated on OC0 PIN
The average voltage on this output pin will be
Vout=
duty
------ x 5v
255
*********************************************************************/
void Wait()
()
{
_delay_loop_2(
(30000);
);
}
void main()
()
{
uint8_t brightness=
=0;
;
//Initialize PWM Channel 0
InitPWM();
();
//Do this forever
while(
(1)
)
{
for(
(brightness=
=255;
;brightness>=
>=0;
=brightness-25)
)
>= ;brightness=
{
SetPWMOutput(
(brightness);
);
_delay_ms(
(100);
);
}