I`m trying to blink led with PWM on Arduino, and I dont know whats wrong. But my LED is not fadeing. What is wrong? I think that I have bad registers settings, but Im not sure. Led is connected on arduino pin 11. Thank you.
#include <avr/io.h>
#include <util/delay.h>
const int delay=1000;
void initialize_PWM()
{
TCCR0A|=(1<<WGM00)|(1<<WGM01)|(1<<COM0A1);
TCCR0B=1;
DDRB|=(1<<PB3);
}
void set_pwm(uint8_t data)
{
OCR0A=data;
}
int main (void)
{
initialize_PWM();
uint8_t brightness=200;
while(1)
{
for(brightness=0;brightness<255;brightness++)
{
set_pwm(brightness);
_delay_ms(1);
}
for(brightness=255;brightness>0;brightness--)
{
set_pwm(brightness);
_delay_ms(1);
}
}
return 0;
}