The below code write a mono character "A" to the 8x8 dot matrix.
Please help me out in how to pick the Data value from serial Read and replace Data = "A".
#include <SPI.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 = 2;
int numberOfVerticalDisplays = 2;
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
String Data ="A";
void setup() {
Serial.begin(9600);
matrix.setIntensity(7); // Use a value between 0 and 15 for brightness
}
void loop() {
matrix.fillScreen(LOW);
matrix.drawChar(0, 0, Data[0], HIGH, LOW, 1);
matrix.write();
}
Since that library used the String class you will need to call the setCharAt() method to insert the char that Serial.read() returns. To show the String on the serial monitor you need to convert the String to a C-style, null-terminated string with c_str().
String Data ="A";
void setup()
{
Serial.begin(9600);
// print original String
Serial.print(Data.c_str());
}
void loop() {
char c;
if(Serial.available()) {
// read character
c = Serial.read();
// replace character at first position
Data.setCharAt(0, c);
// print new String
Serial.print(Data.c_str());
}
}
I tried the same initially, but I face a problem in the display.
Always an unknown character is printed on the display.
When a character is send through the serial command, its displayed for a nano second and vanishes, over the character shown in the picture below.
Initialize the String named Data with a value, in your case A
Determine if there is a character on the serial port (open Serial Monitor on Arduino IDE, type a character, hit the Send button)
If there was a character available, read it and replace whatever character is in the String named Data with the character just read
Write the character in the String Data to the 8x8 dot matrix
#include <SPI.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 = 2;
int numberOfVerticalDisplays = 2;
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
String Data ="A"; // Initialize String Data
void setup() {
Serial.begin(9600);
matrix.setIntensity(7); // Use a value between 0 and 15 for brightness
}
void loop() {
char c;
// is there a character available on the serial port?
if(Serial.available()) {
// read character
c = Serial.read();
// replace character at first position of String Data
Data.setCharAt(0, c);
}
matrix.fillScreen(LOW);
// show character at first position of Stirng Data on the 8x8 matrix
matrix.drawChar(0, 0, Data[0], HIGH, LOW, 1);
matrix.write();
}
Sure. What does a carriage return look like? A line feed? These characters have no visual representation, so they appear to cause the display problems.
PaulS:
Sure. What does a carriage return look like? A line feed? These characters have no visual representation, so they appear to cause the display problems.
This thread may have seemed terse, but look... the OP asked and listened/learned something!
I'm sure he'll be back, but a good example of how the forum SHOULD work!
Thanks PaulS