Greetings Folks, I'm using the AVR Butterfly (Atmega169), and I'm trying to control a PWM I've created using switches connected to PORTB. My code isn't working. My signal is constantly on and can't be changed. Does anyone see my problem or know a better way of doing this? Thanks.
#include
int main (void)
{DDRB = 0x20;
while (1)
{
if (PINB & 0x01)
{
TCCR1A = (1<<COM1A1) | (1<<COM1B1) | (1<<WGM10);
TCCR1B = (1<<CS10);
OCR1A = 125;
}
else if (PINB & 0x02)
{ if (PINB & 0x04)
{ TCCR1A = (1<<COM1A1) | (1<<COM1B1) | (1<<WGM10);
TCCR1B = (1<<CS10);
OCR1A = 125;
}
}
else
{TCCR1A = (0<<COM1A1) | (0<<COM1B1) | (0<<WGM10);
TCCR1B = (0<<CS10);
}
}
}