Tag Archives: Make

Arduino 101 Challenge

I attended an event by MakeICT this past Saturday where they went through the basics of using Arduino Uno R3 micro-controller–which is basically a tiny computer device that you can program to do certain things depending on the devices you might attach to it.? It is especially interesting because it is a really user friendly way of bringing the digital world of coding into the physical world where the output of your code is made visible in one fashion or another.

At the conclusion of the workshop they presented a challenge and I thought it might be of interest to someone, or even for just my own reflection later on, to see my thought process of how I tackled the task at hand.? The challenge is this:

Develop a mock solution using the arduino to simulate a 4-way intersection light traffic control situation.? As an added bonus challenge, incorporate the use of a pedestrian crosswalk request button.

At first glance, this really seems pretty easy, just a bit of busy work to organize the logic, but a fun little challenge to tackle.? I also want to try to see if there is a way I can push it a bit further– perhaps incorporate a new idea that isn’t yet the norm–like a traffic light sensor that can detect if an emergency vehicle is approaching with its lights on and direct traffic accordingly, or perhaps achieving the objective in the fewest lines possible.? Something like that.? First, I will work to achieve the primary objective and then come back and revisit my own added twists if time permits.

So, my first step is to dissect the problem at hand and break it up into bite size pieces, get it really granular and put everything on the table so I can see how the pieces might fit together best.? Then I will have a checklist to help guide my coding strategy.

  • “Camera Sensors” (I will substitute a camera sensor with a light sensor while working with the arduino) will detect traffic from all four directions.? Eight camera sensors in all–two pointing in each direction–one for traffic continuing straight or turning right and one for traffic turning left.
  • Two buttons at each corner will detect? if a pedestrian desires to cross a particular street in a particular direction.
  • The camera detecting traffic going straight or left need to check if there has been a car waiting for a set amount of time and thus requires the light to change to continue on.? The alternate scenario would be if there was a car turning right who had to wait momentarily, but then was able to continue on without the need for the light to change.
  • Another consideration would be the preferred default state of the light.? This would only take effect if there was no detected traffic for a given period of time.? If no traffic is present, the light will default to green for the most commonly traveled direction, thereby decreasing the amount of stopping for the average commuter.
  • Switch to a default program if one of the cameras is not working.
  • Find some way to test if all the sensors are working, if it is determined that one is not working, then an warning signal needs to be set off and the “backup” program needs to take effect.
  • Also need to work out the actual setup and timing of the light colors switching…green, then yellow for x seconds, then red, wait y seconds, then change the perpendicular street’s lights to green…

On my next post I will draw a diagram of the sensors and lights layout and write out the logic for the steps/considerations listed above.

Some other things that might be considered for critical cross sections, but I won’t consider for this test: Additional cameras