So I want to change the duty cycle to 50% of an LED connected to PORTB .The input is being given in PORTD.
So if there's an input in PORTD then the LED should glow at 50% duty cycle, if not then it should perform the LED blink.
The following is my code; is it correct?
#define F_CPU 4000000UL
DDRD = 0b00000000; //All pins in PORTD are inputs
DDRB |= (1 << DDB3); // PB3 is now an output
OCR0A = 64;// set PWM for 100% duty cycle
TCCR0A |= (1 << COM0A1);// non-inverting mode
TCCR0A |= (1 << WGM01) | (1 << WGM00);// fast PWM Mode
TCCR0B |= (1 << CS01); // prescaler to 8
PORTB = 0xff;
PORTB = 0x00;