Hello guys, welcome again to Afros. We are still going to continue with our Arduino series
which is a I Arduino project made easy in our previous videos
we have been seeing how to manipulate the display of led s today
we want to take this project to another level that is by designing a traffic system in purchase eight
with the help of C GP T. But before we start designing our project
let us look at how traffic works at an intersection. The three directions vehicle can go called
movement right through or left, right and through can be grouped together a single movement
So a typical four way intersection has eight vehicles and four pedestrian movement
This movement can be grouped into phases of the traffic signal. For example
the left movement at opposite movement can be grouped into a single phase because they can both go at the same time without conflict
Traffic engineers use ring and barrier diagrams. They left major tones the major street and pedestrians through
movement but to clear the intersection, minor street left stones, minor vehicles
and pedestrians through movement. Hello guys. This is a phonics. It's time for us to design
the traffic system of who gets to go and who gets to wait using Arduino and purchase it
And now let's go for the design. All right. So with that being done
let us design our intersection. So in order for us to design our this interface
as a traffic system or an intersection traffic system, we have to make use of this two D graphics
So you can see there are two D graphics. We have circular
we have triangle, we have a line and then we have a close path
So our first thing we're going to use is this closed path select
Come here, Tia it came from, this is the mid 0.1 to calculate
Here we go meat 12 good
Now here is our intersection kind of we want to make um a road search
So let us now move on to edit, click here, right? Click see edit
property instead of components, we move on to write down as a template
Then you say this will be applied to only this graphic. Click good
Now we have seen. So the next is to find a divider to divide the root with that
we still we go for this triangle good
Now we have to find a divider that will divide this into two lanes
So with that, we still go with our box. All
right. So next we click on this copy computer
click board. Now we can paste it on click board so that we can have a nice
that is good
Now we're done with that. We can highlight all this copy block pasture good
Do the same thing for here, do the same thing for her
Good. We have to do the same thing for this other part
You can take this box. Now
we can copy all this blog and then paste it here. Do
the same thing for her. Good. Now, our interface looks great. Now
we can change the color of this be I want us to change the color is for something you will see the output
It would be very amazing. So with that, let us say we can change it to white
OK? Now I'm going to change the color of all this thing. We should have changed it before
But if you are doing this one, you can change it before you can copy and paste
But let us know I will change them manually as fast as possible
Good. We are done with that. So our next step will be to put the divider
Here we go back to this point. Let us take circular and then you can put it at the middle and
then expand it good. And next
now look at the interesting part of it. We come to this
edit it again, go from template to component again. And this time around we are going to give the color for the template and
the color is going to be black. Now see the magic it example something right
Yes, exactly a road, an intersection route. So you see here is our route we have
this is the we have like four lane 1234. So we are going to put our traffic system for this intersection with
that. Let us go and search for our component so that we can hook the component in here
We come to component mode, we go place component first, we look forward
you know, still go for the same AUO double click. It will be appeared here
Next, we need traffic light, we need traffic light, traffic, look at the traffic light
OK? So, so OK, now let us put our Arduino here and
then we fix our traffic lights another
one here. OK. So this is how the traffic system goes. Ok
Now if the cars are moving this way, they reach at this point
they will all stop. But when all of these are stopped and they give access to this one to move
it will move this way, some will move this way, some will go this way
Likewise this one, it will go straight, some will go this way
some will move this way. OK? Now next, we now going to connect this one to Arduino
But in our previous video, I told you not to use too much of wires in purchase eight purchase
It has that flexibility of using wireless connection inside purchase eight, we go to this terminal mode
On the terminal mode, we have input and output and we know that input
it is entering into the system and output is leaving out the system
So we select input because the input will be entering into this traffic line
So we put connect it here. All
right. So this looks amazing. Next, let us know for the Arduino connection
we know output is leaving out meaning the instruction will be coming out from Arduino into the traffic light system
So we use output to connect to the Arduino two. So let me zoom again
starting from pain two 123123123123
Mind you, we have four traffic lights and each traffic light is having 33 comings
All right, good. So now we connect interesting
All right. So now we have to label our traffic light. So let us call this as lane one
lane two, lane three and lane four 123 and four. So
we start with L 11 that's lane one pin, one, lane two
lane one P two. Alright, so this the way of of labeling
we have to label the same thing so that it will correspond to the terminal
So we start with this first lane and we are going to start with green to red
Likewise the others. So we go cl 11, L 12
L 13. Likewise disorder starting with green L 21
Alright, so we are now done with our connection. Everything looks great
It's now time for us to consult our helper that is the C GP T to generate for us a code
Alright, so now we are in the H GP T um we are going to start a new conversation which will be for traffic light
So the instruction that we should give here, the GP T will generate code based on the instruction that we give
from the description of traffic lights at an intersection of four roads
So this is how I designed my instruction that will be given to I tt that I have four lane intersection for four routes
Each lane has a traffic light that consist of green, yellow and red
Now we say lane one, green, yellow, red is green, is connected to pin two
yellow, is connected to pin three and then red is connected to pin four just like how it is in our circuit
So I have defined everything for T pity. Now I ask GP T here that kindly generate a smart traffic light
at window code at this intersection for the smooth movement of vehicles at this intersection using sequence below
at the initial stage that is cycled one. We are going to give go ahead to only lane one to move
Now lane one will move lane two will be off lane three will be off lane four will be off in cycle two
Lane one will now tell other cars to stop because your time is over
It's the next, it is the time of the next lane. That's why I'm in lane two
It will still be red but yellow will be shown to those in lane two that you have to ignite your vehicle because it's time
for you to go. Then lane four, lane three and lane four will be off
Now when it comes to cycle three, we are putting lane one off
Lane two will now be given the go ahead. Lane three and lane four will be off
Now we now come to lane four that is we allow vehicle to go after
Sometimes we give caution to vehicle that you have to stop and allow the other lane to go at the same time
We are telling those in the other lane that hey ignite your vehicle
get ready because we are about to give you a go-ahead. Then from there
it will be given the go ahead to move. Ok. Now we can copy this whole conversation
Don't worry, the link to this conversation will be in the description below
just check it out. Now we come to pity here and then paste the instruction here and we say stent
ok. Now here is the code. Let us copy this code, put it in our Arduino
ide and see whether it's working perfectly. Now you compile this good
I didn't select my board, go to tools, go to board, then I know uno compile
Everything seems OK? It's giving me error, compile, error case. OK? Compile again
let's say. All right. So it's done compiling good. Now
we look for the hex file. Here is the hex file. So I'm
going to copy that could be, I
will go into our purchase, going to our, do you know control a control V OK
I say, OK? Now let us run and see how the circuit will look like
Ok. Now click on play at Initia but
it is not giving us what we required of it. At first we said we give the song green light and the others will all
be red. So it didn't generate. Imagine this is the downside of A I
So now you just have to try and try and see how it will generate for you
We go again, you click on this button that says regenerate, click
on it. It will generate another version. OK
We copy this one again. We try and see control, control a control
V comp done compilation. Come again
stop and then play. Ok? They're all off, right? That's the first step that we want
Now we want when it is moving to yellow, let this one also move to yellow
telling these guys that get ready. But now good. It says that hey
stop down, slow down because we are about to give it to another lane
But he says something happened in the process. You see it stop
everything just stopped. So it's not working as expected, right? That is one fault but at least we are making progress
right? Stop again. We get into your chatty pity and then it a regenerate again
It will regenerate another version. All
right. So now let us copy this go again into our Arduino control A control
V compile, then compiling, go into a pre
set play. Ok? All are off. Ok. Good. So stop, stop, stop
These cars are moving in this lane one because we consider this as lane one
This is going as lane one next stop
slow down. Then it's telling this guy to come down. So still it is not
working based on expectations, but we are moving ahead. We are making progress
It's just trial and error and we can come again and say regenerate again and see when
it stopped like this, you just click on continue generating. Ok? Now let us try
this code and see this one seems to be very long. Click on copy
go to adrenal ID, control A control V and say compile. Everything
seems to be ok. Done compiling. We get into our preachers, stop when we say run
ok. At first. All off. Good point. Good
Now this is in the slow down, but it's also telling this one to ignite their cars because it's time to move
You see it worked very well here for the first two lane
this one is off. This one is going on. Now, after sometimes while this is telling this lane
while the Adwin is telling this lane to slow down, it will tell these guys to get ready
Let's see, get ready. You slow down. Whilst these guys will now put on
they will ignite their cars and they start moving this guy off. So only this lane next when this one is telling these cars to
slow down because we are about to hand over to lane four
At the same time, it will tell lane four that get ready
We are about to go. Then after that, it will go. Boom
All right. Then after that, let's see how it will handle to this guy
Go to yellow and this guy would have yellow as well. Boom
So guys, you see this is how you do it. GP T is not that perfect
but based on trial and error, sometimes it confuses our message, whatever we want to say
Sometimes it, it is a robot, it is not human to clearly get whatever you are saying
So this is how you go about it with trial and error. Now let me tell you when let's say this guy is giving all
the vehicles will move this way, some will move this way, some will move this way
right? While these ones are stopped this way, this way and this way
fair enough, right? So far, this look amazing because we have tried chat GP T although GP T is not
that perfect, but cha GP T has helped us after we've tried four times for it to regenerate
to regenerate, to regenerate for four times. It gave us when we did that
So guys, this is how you go about using GP T to make a traffic light and mind you here your control site
and here is your diagram. And if you haven't subscribed yet to Aix do that now
so that, you know, miss upcoming videos like this video and share it with someone whom you know
it will be of a great help to. Thank you for watching this video