[Doug] pulls a signal from the 9V AC power before it hits the bridge rectifier ... It’s written for PIC but you’ll have no trouble adapting it to other microcontroller families.