Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 3.51 KB

README.md

File metadata and controls

45 lines (31 loc) · 3.51 KB

SevenSeg4D

Arduino 7segment 4 digits display Library

Overview

This library is based on a great tutorial I found in YouTube made by Kristian Blåsol about driving a 4 digit 7segment LED display screen with 2 HC595 shift registers.

I 've tried many Arduino libraries regarding seven segment display and none of them seem to work, or was to complicated for me to play with more than 1 shift registers (HC595) and 1 7segment LED display with 4 digits.

The code and logic of Kristian Blåsol was very simple and understandable so the SevenSeg4D class was borne in order to make the things a bit simpler.

The class offers 4 public methods:

void shiftOutMsg(char *msg);
void shiftOutChar(unsigned char c, byte digitpos);
void scrollMsg(char *msg, ScrollDirection direction, long delayTime);
void setAllowFloat(bool value);

The first one takes a null terminated buffer of characters and displays them on the 4 digits LED screen and the second one can display only one character at the digit position of our choise. Although the library has not been tested with more than 2 shift registers and a 4 digit 7 segment LED screen it could work with no problems, as long as you respect the wiring as per the video below:

https://www.youtube.com/watch?v=ZGzbAd-Aixc&list=LLwUpbzkpNqzFDXJVHNlYP9w

The scrollMsg function may scroll a message from Left2Right or Right2Left and at the given delay in milliseconds. An example was made at the video below:

https://www.youtube.com/watch?v=3K__viiOc5Q&feature=youtu.be

For those who like a different wiring (e.g. have all common digit (D1..D4) pins connected to the 2nd shift register) the setAllowFloat function does that. Just call it in the setup() function of your sketch with a true parameter as in the following example:
void setup() {
disp.setAllowFloat(true);
...
}
The FloatNum4DSPI.ino demonstrates that functionaliy.

To initiate the class just apply the 3 Arduino pins (data, clock and latch pin) at which you connect your circuit and if you use common cathode or common anode for your 7 segment screen, like the example below:

SevenSeg4D disp(dataPin, clockPin, latchPin, Cathode);

or using the SPI contstructror:

SevenSeg4D disp(latchPin, Cathode);

where you define only the latch PIN. The data and clock PINs are defined automatically as per the SPI Arduino reference

The default constructor uses dataPin = 3, clockPin = 4, latchPin = 2 and an Anode common connection to the 7segment LED display.

In the examples you can find the Counter4D sketch which use the SevenSeg4D library and has been tested successfully on an Arduino Uno board. But other boards (like Arduino Mega, Nano or NodeMCU) can be used either.

Currently the library supports English letters from A-Z, a-z, all numbers 0-9 and a few symbols like (,),+,/ etc. However, more symbols can be added at the sevensegset array which is defined in the corresponding header file.