Note: The led pin is connected to the negative lead of led, resistor, and VCC, thts why PB0 is set to high in the initialization.
Any help is great!
Code: Select all
#include <avr/io.h>
// PB1 is connected to switch (then to GND)
//PB0 is connected to LED (VCC on other side of LED)
#include <util/delay.h>
int main(void)
{
DDRB = 0x01; //all input except PB0
PORTB = 0xFF; //all internal resistors activated and PB0 is high
for(;;){
if(PINB,1==0) { //if button is pressed (no debounce)
PORTB = 0x00; //Set PB0 to ground
_delay_ms(100); //delay
PORTB = 0xFF; //Set PB0 high
_delay_ms(100); //delay
}
}
return 0; /* never reached */
}