After connecting the A0 to 5v+ and some changes made the code working correctly..

Now another challenge is to add trip meter extracted from the odometer..I will connect a push button on A1 of arduino and the GND which will shift the trip meter from TRIP A, TRIP B, TRIP C.And a long press on any A, B or C will reset the trip meter to 0Km..

Will I have to store every trip on separate position on the EEPROM...??

Will I have to store every trip on separate position on the EEPROM...??

Yes, if you want the trip meters to be preserved when you power off and on again. You could maybe use less than 4 bytes per trip meter, but you've got loads of EEPROM space left, so I wouldn't bother trying to reduce the amount of data stored, unless keeping the mcu powered while you write all the data becomes a problem.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

I didnt get this part " unless keeping the mcu powered while you write all the data becomes a problem. "

Did you mean that the more data I want to write the more longer I t wil take to write and hence I will have to use much bigger Capacitor to keep the MCU powered that long...??

Yes. Each byte you write to EEPROM takes 3.3ms according to the EEPROM library documentation, so you have to make sure that the capacitor is big enough to power the mcu for the length of time it takes to recognise the power loss plus the length of time it takes to write all the bytes.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

just display the difference between the odometer reading when the TRIP Meter was reset and and odometer reading present..??

Either, but the second is probably simpler. Store the value of wheelRevs at which each trip meter was last reset, then subtract it from savedWheelRevs and convert the result to km as usual for display. This also means you don't need to write the trip counters to EEPROM when the power goes down - instead, whenever you reset a trip counter, write its wheelRevs to EEPROM immediately.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

You need to save the wheel revs when the trip counter was started in 4 bytes of EEPROM, not one. First, let's write functions to read and write 4 bytes of EEPROM since you will be doing it in more than one place. Add this just before setup():

void setup(){ // Initialise wheel revs from value stored in EEPROM wheelRevs = readEepromLong(odometerEepromLocation); if (wheelRevs == 0xFFFFFFFFUL) { // must be the first time we have run wheelRevs = 0UL; }

void setup(){ lcd.begin(16,2); // Initialise wheel revs from value stored in EEPROM wheelRevs = readEepromLong(odometerEepromLocation); if (wheelRevs == 0xFFFFFFFFUL) { // must be the first time we have run wheelRevs = 0UL; }

void setup(){ lcd.begin(16,2); // Initialise wheel revs from value stored in EEPROM wheelRevs = readEepromLong(odometerEepromLocation); if (wheelRevs == 0xFFFFFFFFUL) { // must be the first time we have run wheelRevs = 0UL; }

const int odometerEepromLocation = 0; // address of the first of 4 bytes in which the total wheel revs is storedconst int TripMeterEepromLocation = 4; // address of the first of 4 bytes where the trip meter wheel revs is stored