Assistance needed with RS232 data and 7 segment display

Hello All,
I am very new to Arduino and my first post. I am looking for help displaying received RS232 data on my 5 digit large seven segment display that I am building for a dirt dragstrip. I have simple code I found that lets me display a value by putting the value in the code manually then uploading to my Arduino Uno. I would like to see if someone can help with the code. The display is driven by the tpic6b595 chip on each digit ( Sparkfun large digit driver) SparkFun Large Digit Driver

The data will arrive as ascii. Data is being sent from a Siemens S7-1200 PLC.
Also suggestion on how to suppress "digit 5" when it is a zero-stay blank - all segments off
the race timing system is set up as 99.999 seconds maximum so I need to suppress the leftmost digit if the trucks pass down the track is under 10 seconds. i don't need a running timer just display the lap time at the end, which I also need to suppress all digits until race is finished.
Thank you to all who have taken the time to read this.

Here is the code

// Define pins for the TPIC6b595 shift register
const int latchPin = 7;
const int clockPin = 5;
const int dataPin = 6;

// Define the bit patterns for each digit on the 7-segment display
const byte digits[] = {
B11111011, // 0
B11100000, // 1
B11011101, // 2
B11110101, // 3
B11100110, // 4
B10110111, // 5
B10111111, // 6
B11100001, // 7
B11111111, // 8
B11110111 // 9

};

void setup() {
// Set pin modes for shift register pins
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}

void loop() {
// Display a number on each digit
displayDigit(4, 1); // Digit 1
displayDigit(3, 2); // Digit 2
displayDigit(2, 3); // Digit 3
displayDigit(1, 4); // Digit 4
displayDigit(0, 5); // Digit 5
delay(5000000); // A lower value here makes the segments that are off flicker
}

// Function to send data to the shift register to display a digit
void displayDigit(int digit, byte value) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, digits[value]);
digitalWrite(latchPin, HIGH);
}

Please keep in mind that we are not a free design or code-writing service. We’re more than happy to help with your design or code, but we need you to make an initial attempt. Please design and write your code, then post it along with an explanation of what’s not working properly.

How to Get the Right Help Faster:

You can spend weeks spinning your wheels, or you might get lucky and solve your problem quickly. To avoid unnecessary delays, it’s crucial to provide an annotated schematic of your circuit as you have it wired, showing all connections, including power, ground, and supplies.

Why Detailed Information Matters:

  • Annotated Schematics: These are essential because they show exactly how your circuit is set up. Without them, it's difficult for anyone to understand what you’ve done, which makes troubleshooting nearly impossible. Fritzing diagrams or unclear pictures are not enough.
  • Technical Information: Many modules look similar and may even have the same name, but they can function differently. This is why we always ask for links to detailed technical information—not just sales pages like those on Amazon, which often lack the specifics we need.
  • Show All Connections: It’s important to include every connection, especially power and ground, in your schematic. Missing these details makes it hard to determine if a setup issue might be causing your problem.

My Process:

When I see a question, I spend a moment assessing it. If it’s missing critical information, I might ask for it. However, if it's repeatedly lacking important details, I may assume the questioner is not serious and move on to another query.

What You Need to Consider:

We don’t know your skill level or what resources you have available. If you’re missing key technical details or seem unprepared, it may indicate that you need to spend more time learning the basics before starting your project.

Providing the right information upfront will help you get the best possible assistance and avoid the frustration of running into dead ends. Let us help you by sharing what you have clearly and completely!

For more guidance, check out this link: Getting Started with Arduino.

1 Like

This an excellent advisory post.
It should be compulsory reading for new arrivals to the hobby.

1 Like

A twiddle-your-thumbs delay of 1.4 hours is required?

1 Like

Lol I know right - It had a value of 500 I think - I first lowered it to 50 and the blink rate increased so i just added a couple 0's to the delay to stop it for now and try to understand why the off segments low level blink. Knowing this section is looping over and over. I'm just learning this stuff. Starting from scratch here.

A big problem is that you have a string of 5 TPIC6B595 shift registers, but you are only sending out eight bits (one TPIC6B595) worth of data at a time. This results in the numbers shifting across the display one digit at a time, causing the blinking effect. Put a delay of 1000mS after each call to displayDigit() to see this slowed down to where it is hopefully easier to understand.

If you shift out all five digits at one time (five digits with eight bits each), then set the latch pin HIGH, there would be no blinking.

Thank You David, will give it a try

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.