#define F_CPU 1000000UL // MHz clock speed #include <avr/io.h> #include <util/delay.h> int main(void) { int y = 1; int x = 0; DDRB = 0xFF; //Makes PORTB as Output while(y) //loop { x += 1; //counting seconds PORTB = 0x00; _delay_ms(1000); PORTB = (1 << PB1); //beeping buzzer _delay_ms(1); if(x == 30){ //30 second mark PORTB = (1 << PB1); _delay_ms(500); //long beep PORTB = 0x00; y = 0;//end loop } } }
the loop isn't ending
also, why is the x value resetting to 0 after the if statement is run