I like traffic lights…

…but not when they don’t work.

The final task I had with Arduino – final meaning I won’t have time to move onto the next task before I hand the report in – was to design a traffic light system using some light-emitting diodes. Yes, I was trying to build traffic lights!

There was just one problem, and it will take a while to explain. To begin, let’s say that the traffic lights were set up for a crossroads with pedestrian crossings. The roads leading into the junction run north-south and east-west. In either case, the traffic was supposed to flow for thirty seconds, and then have a five second yellow light, and then let the other lane flow. If a pedestrian presses a button, then the traffic would come to a halt after the current cycle and the pedestrians would have 10 seconds to cross the road – while the time they have left is displayed on a liquid crystal display.

Or at least, that’s the idea. I had a problem trying to get it to work using a bunch of if loops and constantly checking to see if the button had been pressed, so I went onto the next task: using an external interrupt. The idea here is that the programme (or “sketch”, as they call it) would only call a function to make the pedestrian lights turn green if the button was pressed.

Mostly, this worked, with one small snag: if the button was pressed while the north-south road was flowing or slowing down, the system worked fine. However, if it was pressed again while the other lane was flowing, the board appeared to ignore the instructions to turn the pedestrian lights green after the traffic light turned red. If the button was pressed while the east-west lane was flowing, but had not been pressed while the north-south lane was flowing, it worked as expected. And the really annoying part was that I couldn’t see anything obviously wrong – whatever the problem is, it’s pretty damn subtle!

I like traffic lights…
I like traffic lights…
I like… *he zips his mouth shut*


Tags: , ,

About Philip

I'm a physics graduate, sci-fi writer, budding game designer, and amateur human.

Any comments?

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: