Hello, total newbie here! Does anyone know of an already existing traffic light set-up that uses inductive proximity sensors? We need it for our research, and we are in need of both a breadboard set-up and a program.
Basically, the lights will change depending on which lane has more cars. Two sensors will be placed beneath each lane--the first one located at the start of the lane, and the second one at a much farther distance. This simulates the amount of cars lined up per lane.
Lane 1 will have its first sensor read--if it does not read a car, it will ask the other lane's first sensor to read a car. If a car is detected, the traffic lights will switch accordingly to let that car pass immediately.
However, if in Lane 1, the first sensor reads a car, it will ask the second sensor of that same lane if it reads a car. If there is a car, the program will let it past. If there is no car, the program will read Lane 2 for any cars.
If Lane 2 is filled to its second sensor, it will let that lane pass first. If there are no cars detected in Lane 2, it will let the first lane pass. If no cars are detected for both lanes, then the program will loop until the sensor reads a car.
Attached is the flowchart to this project.
EDIT: we're high school seniors by the way, and this is for our research project
likewaze:
Hello, total newbie here! Does anyone know of an already existing traffic light set-up that uses inductive proximity sensors? We need it for our research, and we are in need of both a breadboard set-up and a program.
Basically, the lights will change depending on which lane has more cars. Two sensors will be placed beneath each lane--the first one located at the start of the lane, and the second one at a much farther distance. This simulates the amount of cars lined up per lane.
Lane 1 will have its first sensor read--if it does not read a car, it will ask the other lane's first sensor to read a car. If a car is detected, the traffic lights will switch accordingly to let that car pass immediately.
However, if in Lane 1, the first sensor reads a car, it will ask the second sensor of that same lane if it reads a car. If there is a car, the program will let it past. If there is no car, the program will read Lane 2 for any cars.
If Lane 2 is filled to its second sensor, it will let that lane pass first. If there are no cars detected in Lane 2, it will let the first lane pass. If no cars are detected for both lanes, then the program will loop until the sensor reads a car.
Attached is the flowchart to this project.
Excellent start with flowchart.
Now annotate your flowchart - instead of m>x describe what m >x means.
Actually use more descriptive name than just "m".
You know that Arduino sketch has basically two "parts" / functions identify which part of the flowchart goes where.
Than identify / name specific process / function , you may even code a specific function which does nothing and place it in the flowchart.
In pseudocode
if(lane 1 sensor inactive )
now check line 2 sensor
if(lane 2 sensor inactive )
go back to start of loop() function
Your next step into translate your flowchart flow into code flow and compile it.
Than you can "fill in" actual code process.
You will find out that controlling dynamic process as counting cars is best when you emulate the dynamic instead of using real hardware.
Sample
#ifdef EMULATE
set line 1 sensor to x #endif
now the line 1 sensor is emulated and the if( ) can be checked / debbuged
if( lane 1 sensor == set to x)
{
process emulated value
...
}
Good luck
likewaze:
Hello, total newbie here! Does anyone know of an already existing traffic light set-up that uses inductive proximity sensors? We need it for our research, and we are in need of both a breadboard set-up and a program.
Most traffic light setups use inductive sensors, usually they are a loop in the road surface working like a simple metal detector.
Are you making a model for proof of concept, or need sensors for full scale traffic light construction.
Can you please tell us your electronics, programming, Arduino, hardware experience?
This sounds like an educatioal institution project.
TomGeorge:
Most traffic light setups use inductive sensors, usually they are a loop in the road surface working like a simple metal detector.
Are you making a model for proof of concept, or need sensors for full scale traffic light construction.
Can you please tell us your electronics, programming, Arduino, hardware experience?
This sounds like an educatioal institution project.
Tom..
We are making the model for a proof of concept so that people may be able to understand our project more. We are more amateurs at electronics and hardware as we rarely make use of these materials, while there are some cases wherein we used Arduino for programming, but we are still not knowledgeable enough. Since we aren't really experienced, we want to get a gist of at least how to wire a sensor to a single led.
Since we aren't really experienced, we want to get a gist of at least how to wire a sensor to a single led.
Start small. Have you tried the Blink example in the IDE. As its name implies it blinks an LED, actually the one built into most Arduinos. Get that running and you will see how to make an LED turn on and off and you can then build on that.
likewaze:
We are making the model for a proof of concept so that people may be able to understand our project more. We are more amateurs at electronics and hardware as we rarely make use of these materials, while there are some cases wherein we used Arduino for programming, but we are still not knowledgeable enough. Since we aren't really experienced, we want to get a gist of at least how to wire a sensor to a single led.
OK. start with "push button to light LED" example code.
After all - your sensor is basically modified pushbutton driving / advancing a simple "car" counter.
Than go back to your flowchart to answer this
If Lane 1 is set to "go green" after the entry sensor COUNTS 10 cars are you going to pass ONLY 10 cars by "exit sensor" and than "switch lines " and let Line 2 go green no matter how many cars are in line 2?
I am asking this to persuade you to concentrate on dynamic nature of your project best to be implement using state machine.
likewaze:
Hello, total newbie here! Does anyone know of an already existing traffic light set-up that uses inductive proximity sensors? We need it for our research, and we are in need of both a breadboard set-up and a program.
In The Netherlands a large portion of traffic lights has these sensors (for many decades already). Possibly the majority of such installations, especially situations where a small, little used road crosses a much busier road. It is a very common way of controlling traffic lights and improving traffic flow.
Or you just want someone to do the code for your project?
Is that the ask?
We have tried programming but we are unsure of whether or not the process is actually correct. Below is our program:
int green1 = 11;
int yellow1 = 10;
int red1 = 9;
int green2 = 8;
int yellow2 = 7;
int red2 = 6;
float metalDetected;
int monitoring;
int MetalDetection = 1;
int s1 = 5;
int s2 = 4;
int s3 = 3;
int s4 = 2;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);
pinMode(s1, INPUT);
pinMode(s2, INPUT);
pinMode(s3, INPUT);
pinMode(s4, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
changeLights();
delay(15000)
}
void changeLights(){
//all reds are on the rest are off
digitalWrite(red1, HIGH);
digitalWrite(yellow1, LOW);
digitalWrite(green1, LOW);
digitalWrite(red2, HIGH);
digitalWrite(yellow2, LOW);
digitalWrite(egreen2, LOW);
UKHeliBob:
Start small. Have you tried the Blink example in the IDE. As its name implies it blinks an LED, actually the one built into most Arduinos. Get that running and you will see how to make an LED turn on and off and you can then build on that.