Glue the face of the LDR (light dependent resistor) to the side of the incandescent lamp as shown below. I like to put the face of the LDR parallel with the harp holding the filament inside the lamp. That seems to yield maximum sensitivity over the range of lamp brightness.
I prefer to use a drop of thick gel super glue for holding the LDR to the side of the lamp. It works great and is clear so it doesn’t obstruct the light from the lamp to the LDR.
Finally, you carefully bend the leads of the LDR at a right angle so they are inline with the incandescent lamp leads.
Next, we’ll test it. Apply the correct power to the lamp, depending on the voltage rating of the lamp you purchased. Incidentally, this device is not limited to our lamps. You can experiment with any lamp by using a rubber band or tape to hold it all in place while testing. You might find a lamp that has a brightness range (voltage on lamp vs brightness) that is more to your liking for your application.
Applying power to the lamp will cause it to glow bright white and impress light on the LDR. The LDR resistance should drop below 1K ohms.
Removing the power to the lamp should cause the LDR resistance to rise above 20 Meg ohms.
Now to encapsulate it.
Slide the tubing on the lamp/LDR combo, centering it between the leads sticking out.
The heat shrink tubing will shrink to about half its diameter when properly heated. Use a heat gun or a hair dryer and apply even heat all around the tubing, holding the heat nozzle 6 to 8″ from the tubing.
Use any opaque adhesive to fill the ends of the tubing. The adhesive should have a high electrical resistance, since the OFF resistance of the LDR is over 20 Meg and we don’t want leakage through the adhesive to cause crosstalk in your circuit.
Preferably, use a thick adhesive so you don’t have to deal with it running while it is setting up.