// // // hello.ftdi.44.echo.c // // 115200 baud FTDI character echo, with flash string // // set lfuse to 0x7E for 20 MHz xtal // // Neil Gershenfeld // 12/8/10 // // (c) Massachusetts Institute of Technology 2010 // Permission granted for experimental and personal use; // license for commercial sale available from MIT. // #include #include #include #include int main(){ double counter=0; double prev=0; double interval=5; double diff; DDRA=_BV(PA7); //128 deximal while(1){ counter++; //printf("%ld\n",counter); //PORTA=_BV(PA7); PORTA=_BV(PA7); _delay_ms(interval/2.0); PORTA=0; _delay_ms(interval/2.0); if(PINA & _BV(PA3)){ //high PORTA=0; }else {//low:button on diff=counter-prev-interval; if(abs(diff)<0.1*interval){ interval=interval+5; } prev=counter; //if(abs(counter-prev-interval)