I'm not any kind of electrical engineer - but here's what I would explore:
(This is all just naive guesswork - anyone who is qualified feel free to correct me)
I would have a 4.5v battery in parallel with your 5v supply, with a diode so that the 5v won't try to charge the battery (but the 4.5 can flow when the 5v drops out). You may need some capacitor and/or inductor to smooth the voltage drop when it happens.
You can also put a reed switch or relay on the battery which is controlled by an mbed digital output, so it can switch the battery off when your work is saved.
Dear friends,
May I know if there is any way to keep the mBed ON for atleast 1s after the main power to mBed is OFF??
I am connecting main power to a digital pin of mBed. If power goes OFF, it will generate a interuupt so that I can save my work before mBed goes OFF. I tried connecting 0.3F 5V capacitor across GND and VIN of mBed but mBed goes OFF as soon as the main power goes OFF.
May I know if there is any hardware solution for this?
Connection details:
Used a diode between main power and capacitor so that capacitor does not gives voltage to main power when main power is switched off.