Ampel screenshot I live about six minutes away from a bus station with a decent connection to the city center, and every morning I just have no time to connect to the Internet and check the timetables to know when to go catch the bus in the coldness of Hamburg's winter.

The idea is then to connect my Arduino, a cheap open-source microcontroller with an Atmel AVR processor, to some lights and inputs to create a light signal that could tell you exactly when to walk outside the door to catch the bus, and whether you can take it easy or should start running.

So, having borrowed Jose's little breadboard atop of an Arduino shield, I was also able to close it in a nifty little box that won't make anybody scream whilst looking at the electronics.

The result?

  • Red: if I go catch the bus, I'll have to wait 10 minutes or more for it. (no way!)
  • Red, blinking: I'd have to wait from 6 to 9 minutes at the bus stop.
  • Yellow: I'll be waiting 5 minutes.
  • Yellow, blinking: Time to get prepared; if I start walking, I'll wait four minutes.
  • Green: Time to go, the bus will arrive after three minutes at the bus stop.
  • Green, blinking: Run! Especially if it blinks at an alarming rate.

Side effects may include arriving always on time to work or taking the bus always when it comes, without even knowing the actual time.

Download

Version Format Download Size
0.2a zip Ampel-0.2a.zip 44.87k
tar.xz Ampel-0.2a.tar.xz 32.16k

Program and schematics are released under the terms of the GPLv3 or any later version. See the details.

Hardware

Included in the software package is the circuit schematic developed using Fritzing's software.
Here's an overview, and the real thing: (click to open the SVG image)

Ampel schematic diagram Ampel in real life

Software

The software is a simple collection of routines, dedicated for the most part:

  • Handle the Arduino time millis() (see this post to prevent a long overflow every 9 hours and a half)
  • Search for the next bus from the compiled timetable
  • Handle the semaphore state (just turned on / in sleep mode / showing the semaphore)
  • Handle the light changing effect

To avoid spaghetti coding I tried applying some principles detailed in Clean Code, trying to make self-explaining functions and keeping it simple.