Hi! I'm working on a SMS-based LED Matrix display. I want to send messages to the Arduino and Display them on the LED Matrix along with other defined strings. Both work well independently, but when I combined the codes, there are errors. Here's what i have been working on:
#include "cmap.h"
#include <SIM900.h>
#include <sms.h>
#include <SoftwareSerial.h>
#define INTEN 6500 //speed the higher the value, the slower the scroll
//-------------------GSM VARIABLES-----------------------
boolean started = false;
char regnum[] = "639339182267";
char passRx[] = "default#"; //holds password, must be 8 char only! and ends with #
char smsdata[160]; //sms only accept 160 char, remaining for header
char numberRx[20]; //holds sender number
char LED_DATA[] = " Hello! ";
//-----------------LED MATRIX VARIABLES------------------
const char CLK = 5;
const char DAT = 6;
const char STR = 7;
const char K0 = A0;
const char K1 = A1;
const char K2 = A2;
const char K3 = A3;
const char K4 = 8;
const char K5 = 9;
const char K6 = 10;
const char K7 = 11;
char Display_Ram[38];
char count;
unsigned char char_pointer = 0x00;
unsigned char mask;
unsigned char shift_counter;
int message_no;
int pins[] = { CLK, DAT, STR, K0, K1, K2, K3, K4, K5, K6, K7 };
int mask_data[] = {0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
unsigned int d;
void setup()
{
gsmsetup();
pinsetup();
}
void loop()
{
// checkSMS();
Display();
shift();
}
void gsmsetup(void)
// ---------- serial setup ----------
{
Serial.begin(9600);
gsm.begin(4800);
}
void pinsetup()
{
for (int x=0;x<=10;x++){
pinMode(pins[x], OUTPUT);
}
for (int y=3;y<=10;y++){
digitalWrite(pins[y],HIGH);
}
for(d=0;d<32;d++){
clock();
}
strobe();
d = 0;
}
void checkSMS()
// ---------- check if there is new message ----------
{
int i;
gsm.readSMS(smsdata, 160, numberRx, 20);
delay(1000);
if (strncmp (numberRx, regnum, 11) == 0)
{
if (strncmp (smsdata, passRx, 8) == 0)
{
while (smsdata[i] != '~')
{
smsdata[i] = smsdata[i+9];
i++;
}
i = 0;
// Serial.print("\nParsed SMS: ");
while (smsdata[i] != '~')
{
// Serial.print(smsdata[i]);
i++;
}
// Serial.println("");
}
}
}
void Display(void)
{
mask = 0x01;
scan();
digitalWrite(K7,LOW);
for(d=0;d<INTEN;d++){}
digitalWrite(K7,HIGH);
mask = 0x02;
scan();
digitalWrite(K6,LOW);
for(d=0;d<INTEN;d++){}
digitalWrite(K6,HIGH);
mask = 0x04;
scan();
digitalWrite(K5,LOW);
for(d=0;d<INTEN;d++){}
digitalWrite(K5,HIGH);
mask = 0x08;
scan();
digitalWrite(K4,LOW);
for(d=0;d<INTEN;d++){}
digitalWrite(K4,HIGH);
mask = 0x10;
scan();
digitalWrite(K3,LOW);
for(d=0;d<INTEN;d++){}
digitalWrite(K3,HIGH);
mask = 0x20;
scan();
digitalWrite(K2,LOW);
for(d=0;d<INTEN;d++){}
digitalWrite(K2,HIGH);
mask = 0x40;
scan();
digitalWrite(K1,LOW);
for(d=0;d<INTEN;d++){}
digitalWrite(K1,HIGH);
mask = 0x80;
scan();
digitalWrite(K0,LOW);
for(d=0;d<INTEN;d++){}
digitalWrite(K0,HIGH);
}
void scan(void){
for (count=32;count>(-1);count--){
if ((Display_Ram[count] & mask) == mask)
digitalWrite(DAT,LOW);
else
digitalWrite(DAT,HIGH);
clock();
}
strobe();
}
void clock(void){
digitalWrite(CLK,HIGH); // clock hi
digitalWrite(CLK,LOW); // clock low
}
void strobe(void){
digitalWrite(STR,HIGH); // strobe hi
digitalWrite(STR,LOW); // strobe low
}
void shift(void)
{
for (int val=0; val<37; val++)
{
Display_Ram[val] = Display_Ram[val+1];
}
shift_counter++;
if(shift_counter == 6){
shift_counter = 0;
load();
}
}
void load(void)
{
char counter1;
char *smsdata= announcement(message_no);
Serial.println(smsdata);
if(smsdata[char_pointer] == '~' || smsdata[char_pointer] == '\0')
{
char_pointer = 0;
message_no++;
goto exit;
}
for(counter1 = 0; counter1 < 5; counter1++)
{
Display_Ram[32 + counter1] = character_data[(smsdata[char_pointer] - 0x20)][counter1];
}
Display_Ram[37] = 00;
char_pointer++;
exit:
counter1++;
}
There's a user-defined library called CMAP.H, i'd post them in the next reply. i ran out of characters.
The problem is, i can't display the text messages. It only displays the message (with a ton of weird ASCII characters) when message_no1 overflows. Any help guys? thanks.