EEPROM example for PIC1814K50

For a previous project involving stepper motors, I wanted the microcontroller to remember exactly where the stepper motor was even after power loss. There wasn’t enough time to attempt it then, so I thought I’d try something similar now.

Each time the PIC starts, it checks the value saved in EEPROM address 0. Depending on this value, it turns on one of four LEDs. Then the variable val is incremented by one and overwrites the previous value in EEPROM address zero. When the PIC is reset this process repeats.