Drive a light bulb from an Arduino program.

A microcontroller isn't very useful without some kind of hardware attached. This exercise introduces driving an incandescent bulb from a digital signal. The transistor is used as a switch to control a higher current flow through the bulb than the Arduino output pin can sink, and at a voltage unsafe for the Arduino.

Steps and observations

  1. Adjust the lamp power supply for a safe full-on voltage. (Many lab incandescent lamps are designed for less than than the 12V shown on the schematic.)
  2. Load and run the Blink sketch from Examples/01.Basics.
  3. Note that pin 13 is still connected to the onboard LED. Observe the bulb and LED activity.
  4. Add additional digitalWrite() and delay() statements to create a different blink pattern.


This simple example cannot drive two separate patterns on two pins simultaneously, since it just stalls during delay(). Much of the challenge of programming a multi-function Arduino program comes down to structuring control flow so the program never stalls so it can service multiple inputs and outputs simultaneously.

For a challenge, restructure this program to use millis() to test for the loop cycles on which to change the output state, then add a second channel of output with different timing. This will covered in more detail in a later exercise.