I have a working matrix scrolling program with the help of a forum member, and now need advice on how to have the time and date scroll twice then have only have the time displayed for, example 5 minutes then have the sequence repeat.
I am using 6xMax7219, DS1307 rtc, and UNO R3.
Program code is enclosed.
[/#include <SPI.h>
#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
int numberOfHorizontalDisplays = 5;
int numberOfVerticalDisplays = 1;
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
RTC_DS1307 rtc;
String tape ="99:99:99 99/99/9999";
int tape_length = 24;
int wait = 50; // In milliseconds
int spacer = 1;
int width = 5 + spacer; // The font width is 5 pixels
int i = 0;
void setup() {
matrix.setIntensity(0); // Use a value between 0 and 15 for brightness
#ifdef AVR
Wire.begin();
#else
Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
rtc.begin();
if (! rtc.isrunning()) {
matrix.print("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop() {
DateTime now = rtc.now();
// modify our tape to show the date and time
tape[0] = '0' + ((now.hour())/10); // I assume you want the time first
tape[1] = '0' + ((now.hour())%10);
tape[3] = '0' + ((now.minute())/10);
tape[4] = '0' + ((now.minute())%10);
tape[6] = '0' + ((now.second())/10);
tape[7] = '0' + ((now.second())%10);
tape[12] = '0' + ((now.day())/10);
tape[13] = '0' + ((now.day())%10);
tape[15] = '0' + ((now.month())/10);
tape[16] = '0' + ((now.month())%10);
tape[18] = '0' + ((now.year())/1000);
tape[19] = '0' + (((now.year())/100)%10);
tape[20] = '0' + (((now.year())/10)%10);
tape[21] = '0' + ((now.year())%10);
for ( int i = 0 ; i < width * tape_length + matrix.width() - 1 - spacer; i++ ) {
matrix.fillScreen(LOW);
int letter = i / width;
int x = (matrix.width() - 1) - i % width;
int y = (matrix.height() - 8) / 2; // center the text vertically
while ( x + width - spacer >= 0 && letter >= 0 ) {
if ( letter < tape_length ) {
matrix.drawChar(x, y, tape[letter], HIGH, LOW, 1);
}
letter--;
x -= width;
}
matrix.write(); // Send bitmap to display
delay(wait);
}
}
code]