Traffic Lights

This page will inform you regarding traffic lights and all the information concerning this topic!

Safety

Traffic lights are an element of security when driving. These lights prevent accidents between cars and cars/pedestrians. Pedestrians would no longer need to run across a dangerous road and have the opportunity to safely cross at their turn. Traffic lights are also used to control the traffic to ensure the flow of the cars, adapting the lights to suit the traffic flow at various times during the day.


Concerns

Even though traffic lights are used to ensure safety for drivers and pedestrians, there are still some concerns.With one small miscoordination in the lights, can result in a huge accident. For example, mis-timing of the lights going in opposing directions can lead to all the cars colliding in the center of the street. Also, if the lights aren’t timed to suit the traffic level, this can lead to build up on traffic in certain lanes, disturbing the traffic flow. Lights malfunctions can lead to concerns. For example, if a light suddenly stops working, it would put the drivers and pedestrians at risk for collisions.

Phishing

We can see that in this picture there's a malfunction with the lights, leaving the drivers not sure whether it's suppose to be a green or red light.


Different Countries

The orientation of the lights varies in different locations in the world. Some countries have lights placed horizontally and others, vertically. For example, here in Ontario, the lights are placed vertically. However, when you drive to Quebec there lights are positioned horizontally.


Features


Requirements

Requirements

Code

This is the code I used to create this traffic lights assignment.

	/* Traffic Lights
	Jieru 
	2017-05-04
 	*/

	int red1 = 2; //red NS light
	int red2 = 12; //red EW light
	int yellow1 = 4; //yellow NS light
	int yellow2 = 10; //yellow EW light
	int green1 = 6; //green NS light
	int green2 = 8; //green EW light


	void setup(){
      	  pinMode(red1,OUTPUT);
          pinMode(red2,OUTPUT);
          pinMode(yellow1,OUTPUT);
          pinMode(yellow2,OUTPUT);
          pinMode(green1,OUTPUT);
          pinMode(green2,OUTPUT);
        }
    

	void loop(){
      	  digitalWrite(red1, HIGH); //red NS light turn on for 11 seconds
          digitalWrite(green2, HIGH); //green EW light turn on for 11 seconds
          delay(11000); //11 seconds
          digitalWrite(green2, LOW); //green EW light turn off 
          digitalWrite(yellow2, HIGH); //yellow EW light turn on for 3 seconds
      	  delay(3000); //3 seconds
      	  digitalWrite(yellow2, LOW); //yellow EW light turn off
     	  digitalWrite(red2, HIGH); //red EW light turn on for 2 seconds
      	  delay(2000); //2 seconds
      	  digitalWrite(red1,LOW); //red NS light turns off
      	  digitalWrite(green1, HIGH); //green NS light turns on for 4 seconds
      	  delay(4000); //4 seconds
      	  digitalWrite(green1, LOW); //green NS light turns off
      	  digitalWrite(yellow1, HIGH); //yellow NS light turns on for 3 seconds
      	  delay(3000); //3 seconds
      	  digitalWrite(yellow1, LOW); //yellow NS light turns off
      	  digitalWrite(red1, HIGH); //red NS light turns on for 2 seconds
          delay(2000); //2seconds
          digitalWrite(red2,LOW); //red EW light turns off
  	}
	

Sources: Wikipedia