The TrafficBlock holds three LEDs: Red, Yellow, and Green.
Each LED has two legs (wires). This means we would need 2x3=6 wires to connect all three LEDs.
However, by sharing a “common” connection, we can reduce the number of wires by sharing the positive or negative side. This is called common-anode or common-cathode.
You can connect the LEDs to any digital pins.
Connect the common (cathode) to any Ground (G) pin
Backwards connections will not hurt the LEDs.
Use the set digital pin block to turn the LEDs on and off.
Make sure the pin numbers match the pins you have connected the LEDs to
We have designed this circuit for only 1 LED to be on at a time -
more than one LED at a time will not work very well (but won't hurt anything).
Can you make the traffic lights work correctly?
Click the picture to download the challenge program: Traffic
Make one set of lights on the screen change everytime you click the spacebar
Make your LEDs work with the lights on the screen
Make the lights change automatically (every 5 seconds or so)
Make the second set of lights on the screen also work
Work with someone else to make two sets of LEDs work with all the lights on the screen
Add safety - do your lights give cars enough time to stop?
What if someone runs the yellow light? (Is the other light still red?)
What if someone runs the red light? (Both lights should be red at the same time for about 1 second)
Use your LineBlock to detect a car waiting at the light and change the light to green (as quickly as is safe)