Vibration / Sound Activated Switch

The sound is detected by the electret microphone then is amplified by the PN2222 NPN transistor. Then the amplified signal is DC converted by the 2 1n4148 diodes.
A comparator is then used to detect the right voltage set by the potentiometer at the inverting input. A small hysteresis is added. The last NPN transistor is the one to drive a relay and with another 1n4148 diode to protect it from the reverse EMF generated by the relay coil when the transistor goes off.