Basically, yes. Set pin 16, or any spare pin, to input mode and connect via a 10K-100K to the +5V line. You will probably also need a bleeder resistor (try 470Ω) across the 5V line so it drops to zero relatively quickly after the mains drops out. Then your code can poll this pin to see if the mains power is on or not.