/* EEPROM Tutorial */

/* 13 Jan 2013 */


unsigned char number, i, pstatus = 0;


void writeNumber( unsigned char number )

{

switch(number)

{

case 0: number = 0b01000000; break;

case 1: number = 0b01111001; break;

case 2: number = 0b00100100; break;

case 3: number = 0b00110000; break;

case 4: number = 0b00011001; break;

case 5: number = 0b00010010; break;

case 6: number = 0b00000010; break;

case 7: number = 0b01111000; break;

case 8: number = 0b00000000; break;

case 9: number = 0b00010000; break;

default: number = 0b01000000; break;

}

PORTD = number;

}

void main() {

TRISD = 0;

pstatus = 1;

while(1)

{

for(i = 0; i<10; i++)

{

if(pstatus == 1)

{

pstatus = 0;

i = EEPROM_Read(0x07);

}

EEPROM_Write(0x07, i);

writeNumber(i);

Delay_ms(1000);

}

}


}