// swecg.c -- ECG simulator on PORTC LEDs; rate adjusted by PORTD switches // implemented and tested on Atmel STK500 with AT90S8515 in rightmost socket // // Copyleft (!C) 2003 S. Mann // (http://www.gnu.org/copyleft/gpl.html); // based on Stephen Lacy's "mirror.c" //#include (doesn't compile when this is there) #include //for the above, you need to apt-get install #include //#include void delay(long N) { long n; for (n=0; n=1) { yi = 0xFF - y; outp (yi,PORTC); delay(d); if (inc) {y=(y<<1)+1; m++;}; if (!inc) {y=(y>>1); m--;}; if (m==8) inc=0; /* decrement */ } y=0; outp (0xFF-y,PORTC); delay(8*d); y=0; outp (0xFF-y,PORTC); delay(2*d); /* chaser speed controlled by switches */ y=1; m=1; inc=1; /* increment: 1=yes; 0=decrement */ while (m>=1) { yi = 0xFF - y; outp (yi,PORTC); delay(2*d); if (inc) {y=(y<<1)+1; m++;}; if (!inc) {y=(y>>1); m--;}; if (m==5) {inc=0; delay(4*d);}; /*change to decrement and delay at top*/ } y=0; outp (0xFF-y,PORTC); delay(74*d); } }