Microntrollers typical have a limited current output; to control larger loads such as motors and lamps, the microcontroller signal is used to control a transistor, which can act as a switch. A voltage applied to the base can control the flow of current between the collector and the emitter:
Project: Dark Detector
https://www.jodyculkin.com/blog/how-to-use-a-breadboard-comic-published
Lightbot: