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

A traffic light controller is to be designed at the intersection of HWY9 and CR6

ID: 665818 • Letter: A

Question

A traffic light controller is to be designed at the intersection of HWY9 and CR66. The intersection is a four way intersection with left turn lanes for both directions of HWY9 and CR66. The traffic light controller will use input sensors to determine if vehicles are waiting in certain lanes and will use that information to determine how the lights at the intersection should be controlled. The inputs and outputs will be implemented onto the Mega2560r3 board using C or C++ programing on the Arduino programmer.

Inputs:

`HWY9 Left Lane Sensor Switch simulates detecting a vehicle waiting to turn left from HWY9.

`CR66 Left Lane Sensor Switch simulates detecting a vehicle waiting to turn left from CR66

`CR66 Sensor switch simulates detecting a vehicle waiting on either side of CR66

`Train sensor switch

simulates a train arriving when in the ON position. While a train is in

the intersection, 2 red LEDs should alternately blink at 1 Hz. (± 10%)

Outputs:

- Red, Yellow, and Green LEDs to indicate the East-West CR66 status

- Red, Yellow, and Green LEDs to indicate the North-South HWY9 status

- Yellow and Green LEDs to indicate the Left Turn Lane status for both Highways

- A strobing LED at 2 Hz with a Duty Cycle of 30% whenever HWY9 is Red

- 2 Red LEDs that are off when no train is present and otherwise blink at 2 Hz

Technology: dip switch, logic bread board, Mega 2560 r3 board.

Priority review of the light sequence: Highest priority is given to the

default state which is Green for HWY9 & Red for CR66 with

all Left lanes not green. The next most priority is given to the CR66

Left Turn lanes followed by a Green light for traffic traveling straight on

CR66. Before returning to the default state, the Left Lanes for

HWY9 have priority if a sufficient number of vehicles are waiting to

turn (ie. 1 or more). If the train going across CR66 is present, the system is in the default position with the addition of the associated train led outputs. This priority characterization is quite normal for T-lights.

Explanation / Answer

TrafficLight.h class TrafficLight { public: enum Signal {RED=0, RED_YELLOW, GREEN, YELLOW}; enum SignalStandard {GERMANY=0, USA}; static SignalStandard signalStandard; TrafficLight(int redLightPin, int yellowLightPin, int greenLightPin, Signal signalState); void enableAlert(int buzzerPin); void switchSignal(); private: int redLightPin; // make uint8_t int yellowLightPin; int greenLightPin; int buzzerPin; Signal signalState; void switchSignalToRedYellow(); void switchSignalToGreen(); void switchSignalToYellow(); void switchSignalToRed(); }; #include "TrafficLight.h"; int autoRed = 1; int autoYellow = 2; int autoGreen = 3; TrafficLight* autoTrafficLight; int pedestrianRed = 4; int pedestrianGreen = 5; int pedestrianAlert = 6; TrafficLight* pedestrianTrafficLight; int pedestrianButton = 7; // Germany uses a red-yellow pattern before turning green. To disable this use // the TrafficLight::USA pattern TrafficLight::SignalStandard TrafficLight::signalStandard = TrafficLight::GERMANY; void setup() { autoTrafficLight = new TrafficLight(autoRed, autoYellow, autoGreen, TrafficLight::GREEN); pedestrianTrafficLight = new TrafficLight(pedestrianRed, NULL, pedestrianGreen, TrafficLight::RED); pinMode(pedestrianButton, INPUT); digitalWrite(pedestrianButton, HIGH); pedestrianTrafficLight->enableAlert(pedestrianAlert); } void loop() { if(digitalRead(pedestrianButton) == LOW) { autoTrafficLight->switchSignal(); pedestrianTrafficLight->switchSignal(); delay(2000); autoTrafficLight->switchSignal(); delay(1000); pedestrianTrafficLight->switchSignal(); delay(10000); pedestrianTrafficLight->switchSignal(); delay(1000); autoTrafficLight->switchSignal(); delay(2000); autoTrafficLight->switchSignal(); pedestrianTrafficLight->switchSignal(); delay(10000); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote