Arduino Coding Fundamentals: The Traffic Light |
---|
Tasks
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.
6. #define directive
4. A close examination of the Arduino pins suggests an optimum location for single Traffic Light.
3. (Hard code everything, no directives, no variables) (pinMode(), digitalWrite(), delay()) Insert your Traffic Light device into digital pins 4-7, facing outwards.
2. Software. First, consider the strengths and weaknesses of the Blink sketch in the context of our ACES reference: Great Code. Since high efficiency and productivity are ACES' priorities, creation of a custom code template is a wise decision. 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.
1. Hardware. The result of Jasper S'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 standard 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. (You, too, will be introduced to the design and production of printed circuit boards in this course and it's not too early to begin to think of a similar board that the ACES that follow you can use to their advantage).
Traffic Light Assembly and Testing. Before you get to the software side of these exercises you'll need to assemble and test your Traffic Light. Your Parts Kit consists of the following components,
Roll over the image to the right to see how Jasper laid out the connections the board. 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. Observe the result. Does this make sense?