/*This is a blink sketch by Joern Kiwitt*/ #include #includ #define F_CPU16000000UL #define LED_IO_PORT DDRB #define SWITCH_IO_PORT DDRA #define LED_OUTPUT_PORT PORTB int main(void){ //set the LED DDR to output (PB2 on the Attiny) LED_IO_PORT=0b00000100; //ste the SWITCH DDR to input (PA7 on the Attiny) - not necessary SWITCH_IO_PORT=0b00000000; while(1){ // Read button if(PINA ==0b10000000){ // Bounce time _delay_ms(5); // Check that it was really pushed if(PINA ==0b10000000) switchLED(); } void switchLED(){ //PA7 is a switch if(PORTA == 0b10000000){ //LED off PORTB = 0b00000100; } else if( PORTA == 0b10000000){ //LED off PORTB = 0b00000100; } }