/* EX 2.3 Light Switch */ /* David Miles November 2006 */ #include /* Set 19.6 MHz clock frequency */ #pragma CLOCK_FREQ 8000000 /* Set PIC16 configuration word */ #pragma DATA _CONFIG1, _EXTRC_CLKOUT & _WDT_OFF & _LVP_OFF void main ( void ) { ansel = 0x00 ; /* set PORTA as digital i/o */ trisa = 0x00 ; /* set all of PORTA for output */ trisb = 0xff ; /* set all of PORTB for input */ /* repeat forever */ while (1){ while ( portb == 0 ) { /* Do nothing */ } porta ^=0X01; while ( portb != 0x00 ) { /* Do nothing */ } } }