Introduction: LinkIt One Tutorials - #14 Traffic Lights
Sometimes in electronics we don't have a specifically designed controller to hand.
In a pinch we can program a different controller to emulate the desired controller.
If we wish to control a device that uses multiple signals at the same time (such as when talking to ICs) we can look at the datasheet for the IC and send the messages using a process called "bit banging".
Bit banging means controlling at least one pin (usually more) at the same time. Usually there is a clock (clk) pin and a data pin.
Each change of the clock pin from high to low or vice versa tells the receiving device to read a bit from the data pin.
We would then give the remote device a certain time period (either microseconds or milliseconds) to read that bit before moving on to the next bit.
A simple way of learning how to bit bang is figuring out how traffic lights work. Sometimes one is on, sometimes two.
In the UK our traffic lights sequence is
RED and AMBER (prepare to go)
AMBER (prepare to stop)
Let's go build some traffic lights :)
Step 1: Materials Required
LinkIt One board
Micro USB cable
4 jumper wires (red, yellow, green, black)
3 1KOhm resistors
3 LEDs (red, yellow, green)
Step 2: Connect the Parts to the LinkIt One
This board is fairly straightforward.
Remove all attached devices (including the USB cable and battery) from the LinkIt One.
We will be using the ground (blue) rail as common ground.
Take the black jumper wire and insert one end into the blue (gnd) rail of the breadboard.
Plug the other end into the GND port of the LinkIt One.
Take the red LED and put the anode (long leg, positive) into column 7 and the cathode (short leg, negative) into the blue (ground) rail.
Take the yellow LED and put the anode (long leg, positive) into column 13 and the cathode (short leg, negative) into the blue (ground) rail.
Take the green LED and put the anode (long leg, positive) into column 19 and the cathode (short leg, negative) into the blue (ground) rail.
For each of the resistors, bend it and place one leg into the same column as the LED and the other leg 3 columns lower.
So for the red LED place one resistor leg in column 6 and the other in column 3.
Take the appropriate wire colour for each LED and insert one end into the column that only contains the resistor leg.
So for the red LED place one end the red jumper wire into column 3 and the other end of the jumper wire in port D4 of the LinkIt One board.
The other two go in D3 (yellow) and D2 (green).
Step 3: Upload the Sketch to the LinkIt One
Download trafficLights.ino and open it in the Arduino IDE.
Upload the sketch to the LinkIt One
Step 4: Where Next?
Traffic lights are a good way to teach basic algorithms.
How about adding 3 more LEDs and making a junction?
How about a crossing button?
"TrafficLights-HagerstownMD" by Original uploader was JoSePh at en.wikipedia - Transferred from en.wikipedia. Licensed under Public Domain via Commons - https://commons.wikimedia.org/wiki/File:TrafficLights-HagerstownMD.jpg#/media/File:TrafficLights-HagerstownMD.jpg