Intro: Getting Started With Arduino - Switched Traffic Light
In this tutorial we are going to build a set of traffic lights (with Green, Amber and Red LEDs)
We'll use a 3 way switch to control which light is lit.
For reference, the switch we will be using is a 3 pin ON-OFF-ON switch
Step 1: Wire Up Your Arduino
Connect an orange wire to pin 8 and a blue wire to pin 7 (these will be the switch wires)
Connect red, yellow and green wires to pins 1, 2 and 3 (these will be the LED wires)
Step 2: Connect Your Switch
Connect the blue wire from pin 7 on the arduino to the left hand contact on the 3-way switch
Connect the orange wire from pin 8 on the arduino to the right hand contact on the 3-way switch
Connect the centre pin on the 3-way switch back to one of the ground (GND) pins on the arduino
Step 3: Connect Your LEDs
The next step is to connect your LEDs. Depending on the type of LED you are using, you might need to add some resistors as described in step 1 of this instructable. Once your LEDs are ready...
Connect the red wire from pin 1 on the arduino to the positive (long) leg of the red LED.
Connect the yellow wire from pin 2 on the arduino to the positive (long) leg of the yellow/amber LED.
Connect the green wire from pin 3 on the arduino to the positive (long) leg of the green LED.
Connect the all negative (short) legs on the LEDs to one of the ground (GND) pins on the arduino.
See the schematic diagram for a configuration of LEDs that uses the minimum number of wires
(paying close attention to the + and - signs on each LED)
Step 4: Write Your Code
The next step is to write some code to control the LEDs.
Download the TrafficLights.ino file and open it up in the Arduino application.
You can tinker with it if you like, or just use it as it is.
For an explanation of INPUT_PULLUP see step 2 of this instructable.