Hi everyone!
I'm working on a retirement gift for a coworker that will count down the days till she's outta there, and I'm having a small issue. I've got the basic 4 panel led board from amazon and am running it with the max72panel library and my issue is this: I clearly don't know enough about what's happening in the code to place a stationary bitmap on the led panels. I know the answer lies somewhere in that for loop, but I've spent a few hours tinkering with it and can't seem to work it out. Any help with where exactly I should look would be very much appreciated. I've scoured the forums and found a few questions about this, but no solutions. For now, I've just thrown in a pot to control the speed. Fun, but not what I'm looking for.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
int numberOfHorizontalDisplays = 8;
int numberOfVerticalDisplays = 1;
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
int spacer = 1;
int width = 5 + spacer; // The font width is 5 pixels
void setup() {
Serial.begin(9600);
Wire.begin();
RTC.begin();
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
matrix.setIntensity(7); // Use a value between 0 and 15 for brightness
RTC.adjust(DateTime(__DATE__, __TIME__));
matrix.setRotation(0, 1);
matrix.setRotation(1, 1);
matrix.setRotation(2, 1);
matrix.setRotation(3, 1);
}
void loop() {
/*if (Serial.available() > 0) {
int tape = Serial.read();
}*/
DateTime now = RTC.now();
int Time = (now.second());
char day[2];
String Day;
Day = String(Time - 60);
String tape = ("");
//int wait = 20;
for ( int i = 0 ; i < width * tape.length() + matrix.width() - 1 - spacer; i++ ) {
int wait = analogRead(A0);
wait = map(wait, 0, 1023, 1, 500);
Serial.println(wait);
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);
}
}