Hi,
I'm pretty certain this is my first post on the forums. I've been tinkering successfully and enjoyably with Arduinos for the best part of 12 years. I've successfully completed numerous projects and have read hundreds, possibly thousands of posts and tutorials over the years so do not post this lightly. I finally seem to have bitten off slightly more than I can chew, thinking that what I was attempting to do was straightforward.
A friend on mine is doing a one man theatre show and wants to display a series of numbers and words (mindful of the limitations of 7 seg displays) behind him as he talks to the audience. The choice of 7 segment displays is deliberate for aesthetic purposes, to be as far removed from a powerpoint presentation and still able to display data on stage.
He wants to cue through the numbers using a simple controller, one button for forward 1 cue 1 button for back 1 cue. The finished show is likely to have somewhere between 50 and 100 numbers/words to display
I thought this would be a doddle, I'll have it for you by the weekend I thought!
I have bought 9 off 6" 7 segment displays, 9 large digit driver boards and have soldered the boards to the digits and wired them all together in the manner described on the sparkfun large digit driver page.
i've connected them to a spark fun arduino Red, which to all intents and purposes seems to act like an UNO but with a bit of extra power handling.
I have fallen at the fist hurdle though
With only the example code provided by sparkfun, which to me was fairly impenetrable to start off with. I've been able to display up to 5 digits using the modified code below:
/*
//This code has been clumsily butchered from the original sparkfun example to try and display larger numbers
Controlling large 7-segment displays
By: Nathan Seidle
SparkFun Electronics
Date: February 25th, 2015
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
The large 7 segment displays can be controlled easily with a TPIC6C594 IC. This code demonstrates how to control
one display.
Here's how to hook up the Arduino pins to the Large Digit Driver
Arduino pin 6 -> CLK (Green on the 6-pin cable)
5 -> LAT (Blue)
7 -> SER on the IN side (Yellow)
5V -> 5V (Orange)
Power Arduino with 12V and connect to Vin -> 12V (Red)
GND -> GND (Black)
There are two connectors on the Large Digit Driver. 'IN' is the input side that should be connected to
your microcontroller (the Arduino). 'OUT' is the output side that should be connected to the 'IN' of addtional
digits.
Each display will use about 150mA with all segments and decimal point on.
*/
//GPIO declarations
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
byte segmentClock = 6;
byte segmentLatch = 5;
byte segmentData = 7;
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void setup()
{
Serial.begin(9600);
Serial.println("Large Digit Driver Example");
pinMode(segmentClock, OUTPUT);
pinMode(segmentData, OUTPUT);
pinMode(segmentLatch, OUTPUT);
digitalWrite(segmentClock, LOW);
digitalWrite(segmentData, LOW);
digitalWrite(segmentLatch, LOW);
int x = 0;
}
void loop()
{
showNumber(12345); //the number to be displayed (changed from 42 in original example)
}
//Takes a number and displays 2 numbers. Displays absolute value (no negatives)
void showNumber(float value)
{
int number = abs(value); //Remove negative signs and any decimals
//Serial.print("number: ");
//Serial.println(number);
for (byte x = 0 ; x < 5 ; x++) //increased this from 2 to 5 to display larger number anything above 6 doesnt seem to work though
{
int remainder = number % 10;
postNumber(remainder, false);
number /= 10;
}
//Latch the current segment data
digitalWrite(segmentLatch, LOW);
delay(300); // I put these delays in to see if it would help with the digits syncing but they are redundant I think
digitalWrite(segmentLatch, HIGH); //Register moves storage register on the rising edge of RCK
delay(300); // I put these delays in to see if it would help with the digits syncing but they are redundant I think
}
//Given a number, or '-', shifts it out to the display
void postNumber(byte number, boolean decimal)
{
// - A
// / / F/B
// - G
// / / E/C
// -. D/DP
#define a 1<<0
#define b 1<<6
#define c 1<<5
#define d 1<<4
#define e 1<<3
#define f 1<<1
#define g 1<<2
#define dp 1<<7
byte segments;
switch (number)
{
case 1: segments = b | c; break;
case 2: segments = a | b | d | e | g; break;
case 3: segments = a | b | c | d | g; break;
case 4: segments = f | g | b | c; break;
case 5: segments = a | f | g | c | d; break;
case 6: segments = a | f | g | e | c | d; break;
case 7: segments = a | b | c; break;
case 8: segments = a | b | c | d | e | f | g; break;
case 9: segments = a | b | c | d | f | g; break;
case 0: segments = a | b | c | d | e | f; break;
case ' ': segments = 0; break; // Can't work out why these cases are inculded when they can't be called or am I just being really thick???
case 'c': segments = g | e | d; break;
case '-': segments = g; break;
}
if (decimal) segments |= dp;
//Clock these bits out to the drivers
for (byte x = 0 ; x < 5 ; x++) // the 5 in this line of code is the number of digits displayed (when increased to 6 to display 123456 things go odd)
{
digitalWrite(segmentClock, LOW);
delay(300);
digitalWrite(segmentData, segments & 1 << (7 - x));
delay(300);
digitalWrite(segmentClock, HIGH); //Data transfers to the register on the rising edge of SRCK
delay(300);
}
}
If I change the code to add 6 digits (having worked up 1 extra digit at a time from the 42 example in the code) or more the number displayed remains 5 digitis long but is truncated ie the first digit is dropped
After lots of research I thought that this might be because of the use of float in the code limiting the number of digits that can be used.
So what I'm moving towards is a program that has an array with 50 to 100 alphanumeric words/numbers
As I understand it these will be displayed in a manner which is different to the technique used in the sparkfun example as I will not be applying mathematical functions to the variables (checking for signs, and decimals etc.) but will be displaying a series of strings. So I think I'm barking up the wrong tree attempting to modify the sparkfun code anyway...
I understand that this using an array of this size may require more memory, so figure that might be a another problem I come up against.
If someone could give me a steer as to how to go about this, I would be truly grateful...
Many thanks for reading and thanks in advance for any help/guidance you are able to offer
Dave