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.
- 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.
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)
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.