Arduino Multi-function Shield

I recently got exposed to Arduino programming and hardware design at the 2019 National Garden Railway Convention in Portland, OR. Geoff Bunza (Blog: https://model-railroad-hobbyist.com/blog/geoff-bunza YouTube: https://www.youtube.com/channel/UCKzeYLMEPxWGilqZTNuG0JA) held an Introduction to Arduino in Model Railroading clinic. As the Clinic Chairman, I offered to help during the presentations in any way I could. Because I’ve been programming forever (since I was a teen), and have been an electronics hobbyist, none of the topics were foreign to me. I had heard of the Arduino, but had never played with one.

This was really fun, using simple components and software to make blinkenlights and such. There are posts such as this one https://maker.pro/arduino/tutorial/how-to-easily-prototype-with-an-arduino-multi-function-shield about this shield, and other examples using libraries to control the devices.

I’m not sure why, but I couldn’t get the libraries to work. They were overly complex for something as simple as controlling a multiplexed display. I attempted to just update the display during the loop section of the sketch, but I couldn’t get the brightness of each segment to be even. Inevitably, the last segment to be updated was brightest (as it was “on” during the loop code) and the others were dim.

I looked for a more basic example using a timer that wasn’t 20,000 lines of code and obfuscation. I found this example that showed how to set up Timer 1 and provide an interrupt handler: http://www.hobbytronics.co.uk/arduino-timer-interrupts That was more like it!

I extended that code and modified my sketch display code to interface with the ISR, and got everything to work well. I built a simple software count-down timer that uses the buttons to set the time and beeps at the end.

Note: I should probably move the display code to a library or something, rather than have so many lines of code.

Leave a Response