Arduino Coding Fundamentals: The Traffic Light
The result of J. Schaffer's (ACES '18) introduction to AutoDesk's EAGLE PCB Layout Application in the Winter of 2017 yielded a simple, but highly-effective, Printed Circuit Board (PCB), for a Traffic Light. We are the fortunate recipients of his design work as you're going to use this device to develop great Arduino coding skills.
51. Create the project, TLExercise51. Determine the value of the second parameter of the Arduino's analogWrite(pin,value) function that results in the red LED's brightness level that is consistent with the yellow and green LEDs. Test it in sequence with the other two LEDs, using an efficient code strategy, to confirm. Think.
50. Pulse-Width Modulation. You're acutely aware that the red LED appears brighter than the yellow or the green (a quick check of any LED datasheet confirms the reason) in this exercise we'll begin to explore how we can address the issue. First, Apple's Breathing LED.
3. #define directive
2. A close examination of the Arduino pins suggests an optimum location for single Traffic Light.
1. (Hard code everything, no directives, no variables) (pinMode(), digitalWrite(), delay()) Insert your Traffic Light device into digital pins 4-7, facing outwards.
0. Go to File > Examples > Basics and open the BareMinimum sketch. Modify the comments to reflect our ACES conventions and save the sketch to your Desktop. At the Finder level, locate the BareMinimum.ino file on your Desktop, copy it, and use it to replace the file by the same name inside the Examples folder of your Arduino application.
Before you get to the software side of these exercises you'll need to solder up your Traffic Light. Your Parts Kit consists of the following components,
Solder the PCB together making sure to orient the LEDs, and male headers, correctly. To confirm you have a working Traffic Light, insert the device into your Arduino into pins 11,12,13 & GND. Upload the Blink Example. The green light should be flashing.