I suggest using the mcu's own EEPROM using one of the following schemes:

1. You are already monitoring the battery voltage, presumably after the ignition key. Therefore, if you power the Arduino via a diode and a large capacitor, you can detect when the ignition has been switched off some while before the Arduino loses power. You could detect the impending loss of power and write to EEPROM then, so that you only do 1 write to EEPROM each time the ignition is turned off (and only if the number of km has changed since last time).

2. You could write to the EEPROM every km but use a wear-levelling scheme so that you don't write to the same cell every time. This would allow you to do well over 10 million km before you approach the 100,000 cycle write/erase lifetime of the built-in eeprom.

I am happy with the option 1. ...

and in option 2. are you telling me to write to the eeprom in this way...??

Yes, that's the basic idea. Since the number of km is monotonically increasing, the highest value in the region you are writing to must be the most recent one. When you want to store a new value, store it in the cell containing the lowest existing value.

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.

To work out how long the charge in the capacitor will last, we need to work out the total current consumption.

The current drawn by the atmega328p depends on the clock speed. The datasheet gives 4.2mA typical, 12mA maximum at 8MHz (it will be nearly double at 16MHz). The last 16x2 LCD I bought draws 4mA maximum. The 555 draws 6mA maximum (less if it is the CMOS type). The regulator will draw 2mA or so more than the output current. So we have a total worst-case current of about 24mA, assuming no other loads on the 5v rail. I assume you will drive the LCD backlight direct from the 12v supply through a series resistor, so that it doesn't draw current from the capacitor.

If the battery provides 12v when not charging (engine idling), you should get about 11.3v after the diode. If you choose a low-dropout 5v regulator, it will provide 5v to the atmega328p with barely more than 5v input. So the capacitor may discharge by about 6v before the 5v supply is affected.

To work out how long the capacitor provides power, we use the equation Q = CV, where Q is charge, i.e. current * time. So:

24e-3 * t = 1500e-6 * 6

which gives t ~= 400ms. So you should have ample time to write the data to flash memory, provided you check for zero battery voltage at least every 50ms or so. Note that these figures assume you run the mcu at 8MHz and use a low-dropout 5v regulator.

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.

It is not a good idea to power the LCD and the MCU from different 5v supplies. Apart from the fact that you would need 2 regulators, if the LCD is powered down while the MCU is still powered, the LCD may put a substantial load on the MCU. You might even damage the LCD.

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.

powering all with the same regulator but only the MCU via a diode and then after that a capacitor so that when the ignition is turned off I do not want to power the LCD with the capacitor, so I will have more time..

No, you need to put the diode and the large capacitor before the regulator, not after it. By putting it before the regulator, you can tolerate a much larger voltage drop on the capacitor (6v in my calculation). If you place the capacitor after the regulator, you can tolerate a much smaller voltage drop - say 0.6v - so you will need around 10 times the capacitance to power the system for the same amount of time.

In addition, with the scheme shown in your schematic, you would still have the problem that inputs to the LCD from the mcu will be at voltages higher than Vcc on the LCD, so the mcu would probably end up powering the LCD anyway.

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.

In my project I just use a simple time out. Once a certain amount of time has passed since the last pulse event I set the values to 0. For RPM this goes by pretty quick since you don't have to track speeds nearly as low as when you're reading road speed. A .5 second timeout would kill the tach at < 120 RPM or so with a wasted-spark ignition? Unless your bike actually idles that slow.

You're already storing the time that the last pulse was received, so when updating the rpm you can just subtract that time from the current time returned by micros() and display 0 if it exceeds the timeout.

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.