Arduino – 2nd Option – Traffic lights

While working on my clock designs I have been looking at backup plans for my Arduino that I could base my work off of. Below is a design for a simple traffic light system.

I could possibly add a bit more interactability to this project, but it was a good way of learning what goes where and why. Below is the general diagram what the circuitry used for this project. Screen Shot 2017-06-08 at 08.48.46.png

Below is the beginning of the code used for this project, like every project I start with defining the LEDs by their ‘name’ instead of the number they are on. This will make it easier later on in the code to control them.

Screen Shot 2017-06-08 at 08.49.01.png

Next is where I configure the LEDs to be outputs, using their new names.

Screen Shot 2017-06-08 at 08.49.03.png

Below is where I program the delays between the lights as you can see the creator of this code detailed out how it works.

The digitalWrite parts show the lights turning off and others turning on, with a delay between each of them (1000 representing 1 second)

Screen Shot 2017-06-08 at 08.49.07.png

This code was fairly simple to grasp so I chose to apply it to a more complex system.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s