#include <p18f1320.h>
//#pragma config WDT = OFF
#pragma romdata CONFIG
_CONFIG_DECL(0x88,0x01,0x00,0x00,0x80,0x03,0xC0,0x 03,0xE0,0x03,0x40);
#pragma romdata
//*****************************************//
char flash_delay (void)
{
if (PORTA == 0x08)
{
// return with a value of 1
return 1; // 1 is passed back to the caller
}
else
{
int j;
for (j = 0; j < 1; j++);
// returning zero means button is not pushed
return 0;
}
}
//*************************************************//
void main (void)
{
ADCON0 = 0x1C;
ADCON1 = 0xFF;
OSCCON = 0xA6;
TRISA = 0x2C;
TRISB = 0x00;
PORTA = 0x00;
PORTB = 0x00;
if (PORTA == 0x04)
{
while (1)
{
PORTB = 0xFF; //turning all the LED,s on
if ( flash_delay() == 1)
{
break; // exit while loop because button is pressed
}
PORTB = 0x00; //turning all the LED’s off
if (flash_delay() == 1)
{
break; // exit while loop because button is pressed
}
}
}
}