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);
}