/* main.c * * Copyright (c) 2003-2004 Susan Cotterell. * Permission to copy is granted provided that this header remains * intact. This software is provided with no warranties. * * Version : 1.0 * * Demo program, flashes LEDs on Port B, responds to switch press on RA1 * */ /* --------------------------------------------------------------------- */ #include /* --------------------------------------------------------------------- */ #define PORTBIT(adr, bit) ((unsigned)(&adr)*8+(bit)) static bit button @ PORTBIT(PORTA, 1); /* --------------------------------------------------------------------- */ main(void) { unsigned i; unsigned char j; TRISB = 0; /* all bits output */ j = 0; for(;;) { PORTB = 0x00;/* turn all on */ for(i = 16000; --i ; ) continue; PORTB = ~j; /*output value of j */ for(i = 16000; --i ; ) continue; if(button == 0) /* if switch pressed, increment */ j++; } }