In Chapter 2, Make Your Own Countdown Timer, we learned how to use a 4-digit 7-segment display and build it as a countdown counter. Now we try to build a digital clock using this module. The algorithm for displaying a digital clock is easy, and is as follows:
Initialize Raspberry Pi GPIO
Perform a looping process
In the looping process, you do the following tasks:
Read the current time
Extract the minute value and then change the minute value on the module
Extract the hour value and then change the hour value on the module
Let's start to implement a digital clock using a 4-digit 7-segment display. We use a 4-digit 7-segment display with two 74HC595 shift registers. We can obtain it on eBay, http://www.ebay.com/itm/291244187011. We can also obtain it on Amazon, http://www.amazon.com/Digital-Display-Module-Board-Arduino/dp/B00W9J08I4/.
Connect the DS/Data, STCP/LATCH, and SHCP/Clock pins from the first 74HC595 to Raspberry Pi GPIO25 (wPi...