Ruffsta wrote:how do you detect a power failure in coding?
Oh, my! Just look
at this lovely can of worms! It's all rusty
… oh, and the lid is bulging, too! Shall we open it?
Generally, detecting power failures is pretty easy to do using the built-in brownout detect (BOD) feature of the atmel 328, but the arduino is set up so that you really can't do that. Briefly, the BOD will jump to interrupt vector 0 when it sees the power dropping, but the arduino is configured to always redirect that the boot loader reset address. That means you can't set up a brown-out interrupt service routine to write to your eeprom.
Well, you can, but it means reprogramming the fuse settings on the 328, and (possibly) disabling the arduino's automatic reset feature.
If you're planning to make a dedicated embedded gizmo using the Boarduino, for example, then you probably don't care about messing up any arduino settings. There are alternative bootloaders available - or maybe you don't use a bootloader at all.
So, the answer depends a lot on how comfortable you are with more advanced embedded programming techniques.