Servo Control with a traffic light system

Hi everyone,

Brand new here and awaiting delivery of my Arduino and trying to get my head around a project I am trying to do.

I need to create a traffic light system, that when the red light displays, a barrier controlled by a servo is dropped to stop cars from moving.

Apologies in advance if my language on the coding side of things is off. Not looking for the code to be written for me just guidance on which direction to look otherwise I will never learn!

Am I right in thinking that I would create an IF statement. IF red light then servo does this ? Or is there an easier way to get the servo to move with the red light.

Start a little earlier... why is the light red, what event or action made it red, and how will you determine it is red (or on, regardless of color). Next is, what to do when these things have occurred.

You would not be the first one with this problem, so google is def your friend here

Try

arduino traffic lights

and see what I mean.

Give N plausible looking sites N minutes each. Read the specifications they are working to, and read read read the code they use to accomplish that.

N depends on too many things. Five to ten might be a start, in other words 0.5 to 1.5 hours of doing nothing but poking around with the goal to see what the possibilities are.

a7

Hi, @juanjo474747
Welcome to the forum.

Sounds like a good starter project.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Hello juanjo474747

Welcome to the worldbest Arduino forum ever.

This is a nice project to get started.

Keep it simple and stupid firstly.
Follow the example code that comes with the libraries to be found in the IDE or
run some tutorials for the hardware selected.
If you are happy with the results of the tutorials you can merge these to your project.

Have a nice day and enjoy coding in C++.

p.s.

Some practical connection information

You can have a blast using this project to learn…
It’s also possible you’ll try to run before you can walk !

Just step into it easy. The basic traffic lights aren’t too hard, but depending on your imagination, and the complexity of the layout, you’ll get in deep - fast.

Just work on getting red+green light sequences, then look at cross streets, amber lights, pedestrian crossings and vehicle sensing, crosswalk buttons etc.

See, it can get out of hand very quickly !

First tip, once you get the red+green basics working, lose delay() and think about millis() timing.

Thank you everyone for the replies

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.