ShowMeTheMuni shows the arrival times of buses to bus stops around my house. This was a relatively small project, so there was very little to post about it. How about we just do a quick summary?
The hardware setup is a Raspberry Pi 1 and a 16×2 character LCD screen I had lying around.
To drive the LCD, I’m using Adafruit’s CharLCD library. The only modification in the library that had to be done was to change GPIO 21, that does not exist in RPi 1, to GPIO 27. That’s actually pretty nice, because it sits right between GPIOs 17 and 22, which are used to drive the LCD anyway.
I have two threads going. One queries nextbus every 30 seconds. The other thread scrolls through the bus lines every 3 seconds. I added a button on GPIO 7 that allows me to scroll faster. The way GPIOs are handled on the RPi is pretty cool – the RPi has on-board pull-up and pull-down resistors. pull-downs are generally better, as there is no confusion with voltages. Then the program can define an event-driven call back. It’s time to try the new syntax highlighting plugin I installed:
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(7, GPIO.FALLING, callback=next, bouncetime=300)
Isn’t that great? you even get debouncing for free.
I taped the whole thing with masking tape, like an idiot, into the box in which my phone was shipped.
Anyway, that’s pretty much it!
I know this is not very comprehensive, but if you have any questions, just drop a line in the comments.
P.S: Check out this guy. He took it a few steps further.