Hi there,
I've built an Arduino based GPS speedometer with GPS receiver, 16x2 LCD dilspay and Arduino UNO board itself. I have to say I didn't experience any difficulties to compose a program code for that since outstanding TinyGPS++, C and SoftwareSerial libs are available. All of them are well developed and look quite straight forward to me. So now I'd like to replace the LCD display with 7 segment LED one where 4 LEDs are driven with 4 of 74595 shift registers. Unfortunately I wasn't able to find anything like LiquidCrystal library but for 7 segment LED + 74595. Could anyone please give me either an example of code or some clue which would help me to translate objects of TinyGPS++ such as "gps.speed.knots()" right into the 7 segment + 74595?
Get your 4 digits to be displayed into an array.
Create a software map of digit to segment:
byte fontArray[] = {
0b00111111, // 0 - DP-g-f-e-d-c-b-a
0b00000110, // 1
etc
and
LED segments:
a
f b
g
e c
d DP
Then send the array to 4 daisy chained shift registers:
digitalWrite (latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, fontArray[dataArray[0]]);
shiftOut(dataPin, clockPin, MSBFIRST, fontArray[dataArray[1]]);
shiftOut(dataPin, clockPin, MSBFIRST, fontArray[dataArray[2]]);
shiftOut(dataPin, clockPin, MSBFIRST, fontArray[dataArray[3]]);
digitalWrite (latchPin, HIGH);
I prefer using
SPI.transfer(fontArray[dataArray[0]]);
myself to take advantage of the faster hardware speed.
Thanks mate for you prompt reply! Your idea does make sense to me pretty much. I'm new with Arduino so I had tried to analyse some existing Arduino codes to gain some understanding of how it works but none of them looked as clear as your one.