I was able to get everything to work before the graduation! Thank YOU!
here is the code that I ended up using.
/*
* Show messages on an 8x8 led matrix,
* scrolling from right to left.
*
* Uses FrequencyTimer2 library to
* constantly run an interrupt routine
* at a specified frequency. This
* refreshes the display without the
* main loop having to do anything.
*
*/
#include <FrequencyTimer2.h>
#define SPACE { \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} \
}
#define HIRE1 { \
{1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0}, \
{1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}, \
{1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}, \
{1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}, \
{1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}, \
{1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}, \
{1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}, \
{1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0}, \
}
#define HIRE2 { \
{1,1,1,1,0,0,0,1,1,1,1,1,0,0}, \
{1,0,0,0,1,0,0,1,0,0,0,0,0,0}, \
{1,0,0,0,1,0,0,1,0,0,0,0,0,0}, \
{1,0,0,0,1,0,0,1,1,1,1,1,0,0}, \
{1,1,1,1,0,0,0,1,0,0,0,0,0,0}, \
{1,0,1,0,0,0,0,1,0,0,0,0,0,0}, \
{1,0,0,1,0,0,0,1,0,0,0,0,0,0}, \
{1,0,0,0,1,0,0,1,1,1,1,1,0,0} \
}
#define ME1 { \
{0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1}, \
{0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0}, \
{0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0}, \
{0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1}, \
{0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0}, \
{0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0}, \
{0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0}, \
{0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1} \
}
#define ME2 { \
{1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0}, \
{1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0}, \
{1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0} \
}
byte col = 0;
byte leds[8][14];
// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[23]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 9, 8, 7, 6, 22, 24, 26, 28, 30, 32};
// col[xx] of leds = pin yy on led matrix
int cols[14] = {pins[16], pins[15], pins[11], pins[06], pins[10], pins[04], pins[03], pins[13]};
// row[xx] of leds = pin yy on led matrix
int rows[14] = {pins[22], pins[21], pins[20], pins[19], pins[18], pins[17], pins[9], pins[14], pins[8], pins[12], pins[1], pins[7], pins[2], pins[5]};
const int numPatterns = 4;
byte patterns[numPatterns][8][14] = {
HIRE1,HIRE2,ME1,ME2
};
int pattern = 0;
void setup() {
// sets the pins as output
for (int i = 1; i <= 22; i++) {
pinMode(pins[i], OUTPUT);
}
// set up cols and rows
for (int i = 1; i <= 8; i++) {
digitalWrite(cols[i - 1], LOW);
}
for (int i = 1; i <= 14; i++) {
digitalWrite(rows[i - 1], LOW);
}
clearLeds();
// Turn off toggling of pin 11
FrequencyTimer2::disable();
// Set refresh rate (interrupt timeout period)
FrequencyTimer2::setPeriod(2000);
// Set interrupt routine to be called
FrequencyTimer2::setOnOverflow(display);
setPattern(pattern);
}
void loop() {
pattern = ++pattern % numPatterns;
slidePattern(pattern, 75);
}
void clearLeds() {
// Clear display array
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 14; j++) {
leds[i][j] = 0;
}
}
}
void setPattern(int pattern) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 14; j++) {
leds[i][j] = patterns[pattern][i][j];
}
}
}
void slidePattern(int pattern, int del) {
for (int l = 0; l < 14; l++) {
for (int i = 0; i < 14; i++) {
for (int j = 0; j < 8; j++) {
leds[j][i] = leds[j][i+1];
}
}
for (int j = 0; j < 14; j++) {
leds[j][13] = patterns[pattern][j][0 + l];
}
delay(del);
}
}
// Interrupt routine
void display() {
digitalWrite(cols[col], LOW); // Turn whole previous column off
col++;
if (col == 8) {
col = 0;
}
for (int row = 0; row < 14; row++) {
if (leds[col][13 - row] == 1) {
digitalWrite(rows[row], LOW); // Turn on this led
}
else {
digitalWrite(rows[row], HIGH); // Turn off this led
}
}
digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.