I recently made a dual 7-segment display board with two IC sockets for attaching the shift registers that drive the displays. I have no problem with writing my own code in the Arduino IDE, but it gets tiring to have to copy the same code to drive the same display over and over again into a new sketch, so I decided to write a library.
ShiftyDigits makes it easier for the user to control two 7-segment displays using two shift registers in series! I am currently working on a version that allows the user to input how many digits are going to be used so they aren’t only limited to two.
I don’t have the resources to include diagrams or schematics and I’m not very good at explaining things but I’m going to try my best. :-\
The setup for ShiftyDigits is fairly simple, but I think it’s important to note that I used individual 7-segment displays with a common cathode on each side of the component.
The dual shift register part of the shiftOut tutorial illustrates the setup perfectly, however you MUST make sure that for each shift register the jumper wires to the display are as follows:
Q0 → Anode F,
Q1 → Anode G,
Q2 → Anode E,
Q3 → Anode D,
Q4 → Anode C,
Q5 → Anode RHDP,
Q6 → Anode B,
Q7 → Anode A.
Also, the ones digit of the display should be attached to the first shift register and the tens digit should be attached to the second shift register
You can attach the resistors however you see fit. I accidentally linked mine to the common cathodes and saw no problem with the performance so I kept it as is (sure beats using 8 resistors!).
In order to test and see if you have the shift registers hooked up properly with the 7-segment displays, the library comes with an example named “RegisterTest.” The first segment of the test shifts numbers and characters into and out of the ones digit, and if the setup is done correctly you should see the numbers ascending from right to left. Ex: “01”, “12”, “23”, “34”, etc. There are other examples included with the library that you can mess around with if you wish. They demonstrate using a potentiometer and button to display a number and create a timer (KnobTimer), using 3 buttons to create a timer (ThreeButtonTimer), and what happens when you increment the number out of or below the given range of 0 - 99 (OlUlDemo).
Now onto the main functionality of the library.
After including the library with your current sketch, you may initialize the the display you are going to be using by entering the following command:
ShiftyDigits displayName(uint8_t dataPin, uint8_t latchPin, uint8_t clockPin)
I have included a few functions and give a brief description of what they do here:
testCycle(uint8_t reps) // Produces the test cycle mentioned earlier in the "RegisterTest" example. countUp(uint8_t countTo) // Counts to a number given by the user countDown(uint8_t countFrom) // Counts from a number given by the user to 0 increment() // Increases the number displayed by one every time this function is called decrement() // Decreases the number displayed by one every time this function is called numDisplay(uint8_t number) // Displays a number given by the user (0 - 99)
I hope I was able to explain everything to an understandable level and I hope this library helps at least one person as I know it will help me in the future. If you have any questions or suggestions for this library feel free to contact me in any way you see fit and I’ll get back to you as soon as possible.
ShiftyDigits.zip (5.17 KB)