• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

traffic light

kiosk

New Member
i am using an Arduino for this project. The IR is set at a specific distance from the traffic light so that if there is a blockage at the sensor it will send data to the microcontroller that there a large volume of cars. The microcontroller will then interpret this data and will provide an output for the traffic light.

I am just a student and a newbie when it comes to programming the arduino. Now, this is my question. Is it possible to extend the time of the GREEN light if there a large volume of cars in the lane? Please help!
 

alec_t

Well-Known Member
Most Helpful Member
It can be done, provided your sensor is able to detect a large queue of vehicles. Your first step is to plan how to use one or more sensors to do this. How will your sensor distinguish between a queue, and just one car blocking the sensor?
 
Last edited:

kiosk

New Member
I am thinking to put the project in a road where there is no vehicle stopping if it is not because of the traffic light like Public Utility Vehicles. That is the purpose of the delay in the microcontroller when it will send signal to the traffic light. If there is a car blocking the sensor for 5 minutes that could mean that there is a large volume of cars in front of the traffic light.
 

alec_t

Well-Known Member
Most Helpful Member
Is it possible to extend the time of the GREEN light
That will depend on whether the Arduino has total control over the light and on things like the type of light and legal considerations (if this is a real-world light, not just a model or project).

Many traffic light systems (in the UK, at least) are already controlled so as to vary the sequence/timing in accordance with traffic queue length as determined by inductive loop sensors buried in the roads.
 
Last edited:

kiosk

New Member
I am just doing a school project. What is traffic light system they are using in UK? Do they use microcontroller in their systems?
 

kiosk

New Member
Does anybody know how can I put a delay in the microcontroller before it sends data to the traffic light?
 

alec_t

Well-Known Member
Most Helpful Member
I'm pretty sure traffic light systems all over the world nowadays use microprocessors.
I agree. Those microprocessors are probably also coupled back to a central traffic monitoring/control centre.
And I doubt the control software or circuitry is in the public domain.
 

alec_t

Well-Known Member
Most Helpful Member
Does anybody know how can I put a delay in the microcontroller before it sends data to the traffic light?
You just use a delay routine in the software.
 

kiosk

New Member
But I think the delay routine is used to only make an LED for example for that specific delay(time)???? Or is it not?
 

alec_t

Well-Known Member
Most Helpful Member
A delay routine can be used for whatever delaying purpose you like, not just LED control, and can provide fixed or variable delays. You could instead configure an in-built timer in the micro to provide a delay.
 

kiosk

New Member
I want to make the micro send data only when the INPUT is HIGH for say, 30 seconds and after that it will send data to the traffic light that it will add time to the GREEN light because there is a long line of cars blocking the sensor. I want to know to do this. I just know how to set the time of the traffic light using the delay function. I used the sketch as follows;

int green1 = 13;
int yellow1 = 12;
int red1 = 11;
int green = 7;
int yellow = 6;
int red = 5;

void setup(){

pinMode(green1, OUTPUT);
pinMode(yellow1, OUTPUT);
pinMode(red1, OUTPUT);
pinMode(green, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(red, OUTPUT);


}

void loop(){
// first traffic light
digitalWrite(green1, HIGH);
digitalWrite(red, HIGH);
delay(10000);
digitalWrite(green1, LOW);
digitalWrite(red, HIGH);
delay(500);
digitalWrite(green1, HIGH);
digitalWrite(red, HIGH);
delay(500);
digitalWrite(green1, LOW);
digitalWrite(red, HIGH);
delay(500);
digitalWrite(green1, HIGH);
digitalWrite(red, HIGH);
delay(500);
digitalWrite(green1, LOW);
digitalWrite(red, HIGH);
delay(500);
digitalWrite(yellow1, HIGH);
digitalWrite(red, HIGH);
delay(2000);
digitalWrite(yellow1, LOW);
digitalWrite(red, LOW);

// second traffic light
digitalWrite(green, HIGH);
digitalWrite(red1, HIGH);
delay(10000);
digitalWrite(green, LOW);
digitalWrite(red1, HIGH);
delay(500);
digitalWrite(green, HIGH);
digitalWrite(red1, HIGH);
delay(500);
digitalWrite(green, LOW);
digitalWrite(red1, HIGH);
delay(500);
digitalWrite(green, HIGH);
digitalWrite(red1, HIGH);
delay(500);
digitalWrite(green, LOW);
digitalWrite(red1, HIGH);
delay(500);
digitalWrite(yellow, HIGH);
digitalWrite(red1, HIGH);
delay(2000);
digitalWrite(yellow, LOW);
digitalWrite(red1, LOW);

}
 

alec_t

Well-Known Member
Most Helpful Member
I'm not familiar with the Arduino, but for a start won't you need code to setup the INPUT function? Then you will need some sort of IF ....THEN routine to test the INPUT and execute a delay(xxxx) before switching green off if there is a traffic queue detected.
 

EE World Online Articles

Loading

 
Top