Hey guys I need some help with some coding. I have a project where I am making a 2 line sign using 8 x 8 led matrix's, each line with its own text and controls. Making a single line sign Is relatively easy, add as many matrix's as you want in line. But I cannot find any reference online to controlling 2 different lines of text on one Arduino board. Is it possible?
Here is my code for a single line sign, thanks to Dejan Nedelkovski @ How To Mechatronics.com;
/*
8x8 LED Matrix MAX7219 Scrolling Text
Android Control via Bluetooth
by Dejan Nedelkovski, www.HowToMechatronics.com
Based on the following library:
GitHub | riyas-org/max7219 GitHub - riyas-org/max7219: Led matrix library
*/
#include <MaxMatrix.h>
#include <SoftwareSerial.h>
#include <avr/pgmspace.h>
PROGMEM const unsigned char CH[] = {
3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space
};
int dIn = 7; // DIN pin of MAX7219 module
int clk = 6; // CLK pin of MAX7219 module
int cs = 5; // CS pin of MAX7219 module
int maxInUse = 2; // Number of MAX7219's connected
MaxMatrix m(dIn, cs, clk, maxInUse);
SoftwareSerial Bluetooth(8, 7); // Bluetooth
byte buffer[10];
char incomebyte;
int scrollSpeed = 100;
char text[100] = "HowToMechatronics.com "; // Initial text message
int brightness = 15;
int count = 0;
char indicator;
void setup() {
m.init(); // MAX7219 initialization
m.setIntensity(brightness); // initial led matrix intensity, 0-15
Bluetooth.begin(38400); // Default communication rate of the Bluetooth module
}
void loop() {
// Printing the text
printStringWithShift(text, scrollSpeed);
if (Bluetooth.available()) { // Checks whether data is comming from the serial port
indicator = Bluetooth.read(); // Starts reading the serial port, the first byte from the incoming data
// If we have pressed the "Send" button from the Android App, clear the previous text
if (indicator == '1') {
for (int i = 0; i < 100; i++) {
text = 0;
- m.clear();*
- }*
- // Read the whole data/string comming from the phone and put it into text[] array.*
- while (Bluetooth.available()) {*
- incomebyte = Bluetooth.read();*
- text[count] = incomebyte;*
- count++;*
- }*
- count = 0;*
- }*
- // Adjusting the Scrolling Speed*
- else if (indicator == '2') {*
- String sS = Bluetooth.readString();*
- scrollSpeed = 150 - sS.toInt(); // Milliseconds, subtraction because lower value means higher scrolling speed*
- }*
- // Adjusting the brightness*
- else if (indicator == '3') {*
- String sB = Bluetooth.readString();*
- brightness = sB.toInt();*
- m.setIntensity(brightness);*
- }*
- }*
}
void printCharWithShift(char c, int shift_speed) { - if (c < 32) return;*
- c -= 32;*
memcpy_P(buffer, CH + 7 * c, 7); - m.writeSprite(32, 0, buffer);*
- m.setColumn(32 + buffer[0], 0);*
- for (int i = 0; i < buffer[0] + 1; i++)*
- {*
- delay(shift_speed);*
- m.shiftLeft(false, false);*
- }*
}
void printStringWithShift(char* s, int shift_speed) {
_ while (*s != 0) {_
printCharWithShift(*s, shift_speed); - s++;*
- }*
}
void printString(char* s)
{ - int col = 0;*
_ while (*s != 0)_ - {*
_ if (*s < 32) continue;_
_ char c = *s - 32;_
memcpy_P(buffer, CH + 7 * c, 7); - m.writeSprite(col, 0, buffer);*
- m.setColumn(col + buffer[0], 0);*
- col += buffer[0] + 1;*
- s++;*
- }*
}
What do I do different?
Thanks for any help you could give me.
DJ Bud