I have two seven segment displays connected to an Ardunion Mini Atmega328. I can display any two digit number I send to the serial interface. However I would also like the displays to:
a. turn all LEDs off when i send a non integer via serial
b. have only one display on when showing single digits
Normally the displays show 00 and then when a single digit is sent it shows 0X where x is the digit. I would like the second display to be OFF when not showing any digits.
is this possible? can you provide sample code to demonstrate this?
Thank you.
You’d need to write your code to look for a specific character and not light up any segments when that character is sent. The space character (Hex 20) would be a good one to use.
That way if you wanted to display " 1" rather than “01”, you’d send a space then the number 1.
Unfortunately we don’t have any example code for this, but it shouldn’t be too hard to add to your existing program.
Hello andresleon,
Try and see if setting each digit with their command bytes might work, from the [Datasheet Wiki:
// ... after initializing Serial at the correct baud rate..
Serial.write(0x76); // Clear the display
Serial.write(0x7B); // Digit 1 control
Serial.write(0b01100010); // set segments B, F, G
Serial.write(0x7C); // Digit 2 control
Serial.write(0b00011011); // set segments A, B, D, E
Serial.write(0x7D); // Digit 3 control
Serial.write(0b00101110); // set segments B, C, D, F
Serial.write(0x7E); // Digit 4 control
Serial.write(0b01010011); // set segments A, B, E, G
Try changing the segment ‘string’ to (0b00000000)](Special Commands · sparkfun/Serial7SegmentDisplay Wiki · GitHub)
Thank you! I will try this when I get home.
TS-Brandon:
Hello andresleon,
Try and see if setting each digit with their command bytes might work, from the [Datasheet Wiki:
// ... after initializing Serial at the correct baud rate..
Serial.write(0x76); // Clear the display
Serial.write(0x7B); // Digit 1 control
Serial.write(0b01100010); // set segments B, F, G
Serial.write(0x7C); // Digit 2 control
Serial.write(0b00011011); // set segments A, B, D, E
Serial.write(0x7D); // Digit 3 control
Serial.write(0b00101110); // set segments B, C, D, F
Serial.write(0x7E); // Digit 4 control
Serial.write(0b01010011); // set segments A, B, E, G
Try changing the segment 'string' to (0b00000000)
[/quote]</QUOTE>
Thank you Brandon. Do you know if these instructions would work on the large displays ([https://www.sparkfun.com/products/8530](https://www.sparkfun.com/products/8530))? i'm using the large digit driver to control them ([https://www.sparkfun.com/products/13279](https://www.sparkfun.com/products/13279))](https://github.com/sparkfun/Serial7SegmentDisplay/wiki/Special-Commands)
Without a full test myself, of which I don’t have all the materials, I can’t say for certain. However, in the [Hookup Guide is seems that there are some definitions that may work.
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;
case 'c': segments = g | e | d; break;
case '-': segments = g; break;
}
](Large Digit Driver Hookup Guide - SparkFun Learn)
TS-Brandon:
Without a full test myself, of which I don’t have all the materials, I can’t say for certain. However, in the [Hookup Guide is seems that there are some definitions that may work.
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;
case ‘c’: segments = g | e | d; break;
case ‘-’: segments = g; break;
}
[/quote]</QUOTE>
This is the same code I am using. However when I pass the space character the displays go to zeroes. It doesn't turn them off. any other ideas?](https://learn.sparkfun.com/tutorials/large-digit-driver-hookup-guide)
I was able to figure out how to blank the screen and get rid of the leading zeroes for single digits. If anyone needs this you can find the code at
https://github.com/andres-leon/seven-se … ay-arduino
i’m sure there are more elegant ways to do this but so far I think it has been working alright.