Traffic light optimization

My project consists on traffic light optimization using webster algorithm and using sensors which they detect in which way the flow of the cars is greater in order to give them priority first. I want a code in arduino which satisfy this condition.

Ardit1995:
I want a code in arduino which satisfy this condition.

Who the hell do you think you are asking for a complete and complicated code randomly from the general forum?

If you have a specific problem or don't know where to start, that is different. But if you want someone else to do your programming, post it in the "gigs and collaborations" section of the forum.

Ardit1995:
I want a code in arduino which satisfy this condition.

If that line should read "I want to code it in Arduino..." then alright, you're granted to do so :slight_smile:

can anybody help me with the code ?
It would be very helpful, thank you.

Of course, show us what you have including schematic (no Fritzing breadboard mess) :slight_smile:

can anybody help me with the code ?

Post what you have, using code tags, and describe the problems, as documented in the "How to use this forum" sticky.

Or are you just hoping to get something to submit for a class assignment?

BTW traffic light algorithms and linking all the elements together are remarkably complex.
The individual functions are simple enough, but ensuring there is no contention or potential for accidents - and fail-safe conditions means a lot of work.

Remember pedestrians, level crossings, start+turn-only lanes and all that other stuff...!

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

If you want help, we need to see that you have made an attempt to get some code together.

Thanks.. Tom.. :slight_smile:

I do not how familiar are you with webster algorithm but the following code explains perfectly the idea. The problem is that the code below is just as a structure because the data come from the sensors in which is expressed at void activate(phase ph). Can you give me a hand how to manage it?

#include

using namespace std

int volume1(){//returns the number of cars in direction 1
int nbofcars1;

return nbofcars1;
}
int volumee2(){//returns the number of cars in direction 2
int nbofcars2;

return nbofcars2;
}
void activate(phase ph){

}
int main()
{
double c=150; //this is the saturation flow per hour nb. of cars per hour
double L=3.2;//yellow time
double c0;//cycle length

c0=(1.52L+5)/(1-(v1+v2)/c); // webster algorithm in order to find the cycle
double totgreen=c0-(2*L);//total green time

int v1=volume1();
int v2=volume2();

double green1=v1totgreen/(v1+v2);//green time for the first phase
double green2=v2
totgreen/(v1+v2);//green time for the second phase
if(green1>green2) activate(phase1);//turn semaphore1 green if it has more flux of cars
else activate(phase2);//turn the other semaphore otherwise

return 0;
}

You naughty boy! Didn't read the link TomGeorge gave you. Please read it and make changes accordingly :slight_smile:

Why bother posting such obvious nonsense?

In the following line, c0 is calculated from mystery constants, and two variables that are not even defined the first time through:

    c0=(1.5*2*L+5)/(1-(v1+v2)/c); // webster algorithm in order to find the cycle

I do not how familiar are you with webster algorithm but the following code explains perfectly the idea. The problem is that the code below is just as a structure because the data come from the sensors in which is expressed at void activate(phase ph). Can you give me a hand how to manage it?

#include <iostream>

using namespace std

int volume1(){//returns the number of cars in direction 1
     int nbofcars1;
      
    return nbofcars1;
}
int volumee2(){//returns the number of cars in direction 2
     int nbofcars2;
      
    return nbofcars2;
}
void activate(phase ph){
   
   
}
int main()
{  
    double L=3.2;//yellow time
    double c0;//cycle length
    double y;
    
    c0=(1.5*2*L+5)/(1-Y);
    double totgreen=c0-(2*L);//total green time
    
    int v1=volume1();
    int v2=volume2();
    
    double green1=v1*totgreen/(v1+v2);//green time for the first phase
    double green2=v2*totgreen/(v1+v2);//green time for the second phase
    if(green1>green2) activate(phase1);//turn semaphore1 green if it has more flux of cars
    else activate(phase2);//turn the other semaphore otherwise
    
    return 0;
}

Do not worry about that because I can fix it , my problem is at activate phase because I do not know how to manage it?

The code explains nothing. So far, you have not posted a question that makes any sense.

What do you mean by "Can you give me a hand how to manage it'?

Manage what?

What is "active phase"? What do you want to manage?

Methinks your problem is that you haven't thought through what the problem is. What do you want to do? How should it be done? What are your parameters and variables? How do they interact? What is the current situation, and which points do you want to optimise?

The moment you have defined your problem, the code will follow easily enough. Code is just code, you may run into problems there but that are programming problems and you don't have that (yet) as far as I can tell. Your real problem seems to be that you don't know the problem you're trying to solve.

My project consits on building with arduino a traffic light optimation using webster algorithm. Since I am not good at coding could you help to realize it.

Forum members generally don't do class assignments, but if you post in the Gigs & Collaborations forum section, you may be able to hire someone.

Or if you start to answer questions and start giving more details (and not simply copying the starting post again), people are wiling to hep you and give you hints.