#include <TM1637.h>
TM1637 TMx0;
char buffer[5];
void setup() {
Serial.begin(9600);
Serial.println("Type your text for the third display.");
Serial.println("Now displaying \"----\".");
TMx0.begin(4, 5, 4); // clockpin, datapin, #digits
TMx0.displayClear();
TMx0.setBrightness(7); // full brightness, default is 3
TMx0.displayPChar("----"); // Initial text on third display
}
void loop() {
unsigned long currentMillis = millis();
// -----------------------------------------
// Third display
// -----------------------------------------
if (Serial.available() > 0)
{
int inChar = Serial.read();
if (isprint(inChar))
{
for( int i=0; i<3; i++) // shift buffer to the left
buffer[i] = buffer[i+1];
buffer[3] = (char) inChar; // add new character
buffer[4] = '\0'; // add zero-terminator
}
TMx0.displayPChar(buffer); // display the new text
};
}