Now I’ve been working on a more ambitious project! I’m trying to build a sports timing clock in a 5w x 2h configuration (160x32 pixels) using an Arduino Due.
I’ve tested the panels in a 5x2 configuration using the “Game of Life” example sketch and it worked as expected.
However for the real project, I have a separate sports timing device that outputs the running time over an RS232 serial connection. It outputs the time every 1/10sec, so the Arduino is receiving 10 packets of serial data every second. I’ve written a sketch that receives and displays the data correctly over the serial monitor.
Code: Select all
String serialInput;
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
while (Serial1.available() > 0) {
byte incomingByte = Serial1.read();
serialInput.concat(char(incomingByte));
if(incomingByte == 4) { // 4 is end of packet character
Serial.println(serialInput);
serialInput = "";
}
}
}
Code: Select all
#include <SPI.h>
#include <DMD2.h>
#include <fonts/Arial_32.h>
const int WIDTH = 5;
const int HEIGHT = 2;
const uint8_t *FONT = Arial_32;
SoftDMD dmd(WIDTH,HEIGHT);
DMD_TextBox box(dmd);
String serialInput;
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
dmd.setBrightness(100);
dmd.selectFont(FONT);
dmd.begin();
}
void loop() {
while (Serial1.available() > 0) {
byte incomingByte = Serial1.read();
serialInput.concat(char(incomingByte));
if(incomingByte == 4) { // 4 is end of packet character
dmd.drawString(0,0,serialInput);
Serial.println(serialInput);
serialInput = "";
}
}
}
I guess the Ardunio isn’t coping with the 5x2 display and reading the serial data, but I’d hoped using the Due would remove any processor issues.
I've read other forum topics with some mentioning the clock divider. My understanding is that the Due uses an 84 MHz cpu with a divider of 20 set in the DMD2 library giving 4.2MHz for the panels, which only actually need 256 KHz for 5x2? Maybe my maths or understanding is wrong...
Can my code be structured better to handle both tasks? Any advice appreciated.