This well-known circuit triggers a relay when light striking the phototransistor is cut off. The transistor can be the BC548 and the relay of 50 mA or less with voltages from 5 to 12 V depending on the power. The 18k resistor can be replaced by a 100k potentiometer to have a sensitivity adjustment.