hi guys i faced a problem in my graduation project and I hope you can help me to solve it ...
my project is connecting Arduino uno to 16x32 Dot Matrix Display(DMD) and display messages on it from vb.net program , I wrote my vb.net program to convert the input text into 2d binary array , the number of columns depend on the text width, as we know Arduino UNO SRAM is too small just 2 Kbytes, so can't receive all the columns and display it , I tried to receive 100 columns in Arduino code and display it then send star '*' to computer to receive the second 100 columns and display it and so on. but it didn't works.
can anyone tell me where is the error part in the code, or if you have another idea to solve this problem
I'm sorry for my poor English
vb.net Code for sending the 2d array ar(,)
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim la As String
If CheckBox1.Checked Then
la = "arabic"
Else
la = "english"
End If
SerialPort2.Write("#" + cols.ToString + "#" + "" + la + "")
Dim INDEX As Integer = 0
SerialPort2.Open()
While INDEX <= cols
Dim see As String = SerialPort2.ReadLine().ToString()
If see = "*" Then
Dim BUFFER(16) As Byte
For I = INDEX To INDEX + 100
If I < cols Then
For J = 0 To rows - 1
BUFFER(J) = ar(I, J)
Next
SerialPort2.Write(BUFFER, 0, 16)
End If
Next
INDEX += 100
End If
End While
SerialPort2.Close()
End Sub
C++ Code for receiving 100 columns and display them:
#include <SPI.h>
#include <DMD2.h>
SoftDMD dmd(1,1);
void setup() {
Serial.begin(9600);
dmd.setBrightness(255);
dmd.begin();
}
long Wid;
void loop() {
if(Serial.available()){
String st = String(Serial.readString());
Wid = (st.substring(st.indexOf('#')+1, st.lastIndexOf('#'))).toInt();
//String Language = st.substring(st.indexOf('')+1, st.lastIndexOf(''));
}
long ind = Wid ;
while(ind >= 0 ){
Serial.println("*");
if(Serial.available()>1 ){
boolean pixls[16][100];
getArray(pixls);
displayArray(pixls);
ind-=100;
}
if(ind >=Wid){
ind = wid ;
}
}
}
void getArray(boolean arr[16][100]){
byte serialData[16];
for(int k = 0 ; k < 100 ; k++){
Serial.readBytes(serialData,16);
for(int i = 0 ; i < 16 ; i++){
arr_[k]= serialData*;_
_ }_
_ }_
_ }*_
* void displayArray(boolean arr[16][100]){*
* for(int h = 0 ; h <= 100-33 ; h++){*
* for (int i = 0 ,g=h; i < 32 ,g<h+32; i++ ,g++){*
* for (int j = 0 ; j < 16 ; j++){*
* dmd.setPixel(i,j,(arr[j][g] == 1) ? GRAPHICS_ON : GRAPHICS_OFF);
_ }_
_ } _
_ delay(100);_
_ }_
_ }_
this code works with me , when sending just 100 columns of the array :
vb.net code :
_ SerialPort2.Open()*_
* Dim BUFFER(16) As Byte*
* For J = 0 To 100*
* For I = 0 To rows - 1*
* BUFFER(I) = ar(J, I)*
* Next*
* SerialPort2.Write(BUFFER, 0, 16)*
* Next*
* SerialPort2.Close()*
c++ code :
* #include <SPI.h>*
* #include <DMD2.h>*
* SoftDMD dmd(1,1);*
* void setup() {*
* Serial.begin(9600);*
* dmd.setBrightness(255);*
* dmd.begin();*
* }*
* void loop() {*
* boolean pixls[16][100];*
* for(int i=0 ;i<100 ; i++){*
* for(int j=0 ;j<16 ; j++){*
_ pixls[j]=0;
* }
}
if(Serial.available()>0){
getArray(pixls);
for(int i=0 ; i<100 ; i++)
{
displayArray(pixls);
}*_
* }*
* }*
* void getArray(boolean arr[16][100]){*
* byte serialData[16]; *
* for(int k = 0 ; k < 100 ; k++){*
* Serial.readBytes(serialData,16);*
* for(int i = 0 ; i < 16 ; i++){*
arr_[k]= serialData*;
}
}
}*_
* void displayArray(boolean arr[16][100]){*
* for(int h = 0 ; h <= 100-33 ; h++){*
* for (int i = 0 ,g=h; i < 32 ,g<h+32; i++ ,g++){*
* for (int j = 0 ; j < 16 ; j++){*
* dmd.setPixel(i,j,(arr[j][g] == 1) ? GRAPHICS_ON : GRAPHICS_OFF);
_ }
}
delay(100);
}
}*_