Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program: Write an Arduino sketch to simulate the traffic lights at 19^th and Bos

ID: 3804573 • Letter: P

Question

Program: Write an Arduino sketch to simulate the traffic lights at 19^th and Boston. The lights should cycle green rightarrow yellow rightarrow red, with a shorter cycle time for Boston traffic and a longer cycle time for 19^th St. There should be a short period when lights are red for both directions to avoid accidents. You could use realistic cycle-lengths, but you'll get tired of waiting for a full day's worth of cycles. So you might use a 5-second green and 1-second yellow for Boston and an 15-second green and 2-second yellow for 19^th St. with a 1 second period of red-both-ways. When a pedestrian is present, the green-light cycle length should be increased by 2 seconds for a pedestrian crossing Boston, and 4 seconds for a pedestrian crossing 19^th St. When an emergency vehicle is detected, switch to solid red for both directions, until 2 seconds after the emergency vehicle is gone. From 10 PM to 7 AM, the lights should go to flashing red (Boston) and yellow (19^th St.). Again, to avoid needing 24 hours to test your simulation, you may use 1 full cycle per hour for Red/Yellow/Green, and 2 flashes for Yellow/Red flashing. I don't know what happens with the lights if a pedestrian presses the button between 10 PM & 7 AM...you can choose whether to give the pedestrian a green light, or just leave it blinking. Your program should use Serial print(...) to print a log of what is happening on your computer screen. This will help the grader verify your program does what it should. The log should show what state the light is in, what the time delay is, and whether there are pedestrians waiting or an emergency vehicle coming.

Explanation / Answer

Iteration #1

sampleMean =

    0.3988

Iteration #2

sampleMean =

    0.3988    0.4950

Iteration #3

sampleMean =

    0.3988    0.4950    0.5365

Iteration #4

sampleMean =

    0.3988    0.4950    0.5365    0.4870

Iteration #5

sampleMean =

    0.3988    0.4950    0.5365    0.4870    0.5501


overallMean =

    0.4935