#include #include #include #define blink_delay 10 #define bit_mask(x) (1 << (x)) // indexes, bit mask, this is similar to _BV(x)?? #define check_bit(x,b) x&b // checks the bit 0?1? #define set_bit(x,b) x|=b; // sets the bit #define clear_bit(x,b) x&=~b; // sets the bit oppisite to the bit #define flip_bit(x,b) x^=b; // flip // pin info // led = Pin10 = PA3(ADC3/T0/PCINT3) #define led_pin 3 // button = Pin 6 = PA7(PCINT7/ICP/OC0B/ADC7) #define button_pin 7 // first readed Dan's class page // http://fab.cba.mit.edu/classes/863.14/people/dan_chen/embedded-programming/index.html // but he seems to connect the button to a PB pin.... // I looked around other attempts and found this code readable // http://fab.cba.mit.edu/classes/863.14/people/sarah_edris/files/week07/hello.ftdi.44.echo.c int main(void){ set_bit(DDRA,bit_mask(led_pin)) // sets direction of the led_pin of port A as output clear_bit(DDRA,bit_mask(button_pin)) // sets direction of the button_pin of port A as input // Looping forever while(1){ if(check_bit(PINA,bit_mask(button_pin))){ clear_bit(PORTA,bit_mask(led_pin)) }else{ set_bit(PORTA,bit_mask(led_pin)) } } return 1; }