With this simple circuit configuration, an optoisolator can drive a standard 2N2222 transistor output high or low to indicate if the line voltage is 120 V or 220 V ac.