Friends, my team and I are working on a gsm based wireless display as a part of our project. We are using Arduino UNO as the microcontroller which is interfaced with a sim900 module. Upon arrival of a new sms in the gsm module, its contents will be passed on to the dot matrix led display through SoftwareSerial. We almost got the code working but the problem we now encounter is the reception of new sms. The code works fine for the first sms but to display the next new sms, we had to manually reset the Arduino every time. Can you guys help me? This is the code:
#include <SoftwareSerial.h>
#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
int temp=0,i=0,x=0,k=0;
char str[160],msg[160];
void ScanDMD()
{
dmd.scanDisplayBySPI();
}
SoftwareSerial SIM900(0, 1);
void setup()
{
Timer1.initialize( 5000 );
Timer1.attachInterrupt( ScanDMD );
dmd.clearScreen( true );
Serial.begin(9600);
SIM900.begin(9600);
void SIM900power();
delay(20000);
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0\r");
delay(100);
}
void SIM900power()
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(7000);
}
void loop(){
for(unsigned int t=0;t<60000;t++){
void serialEvent();
if(temp==1)
{
x=0,k=0,temp=0;
while(x<i)
{
while(str=='#')
{
x++;
while(str!='*')
{
msg[k++]=str[x++];
}
}
x++;
}
}
}
const char* dchars;
dchars=msg;
dmd.clearScreen( true );
dmd.selectFont(Arial_Black_16);
for(unsigned int i=0;i<=300;i++){
dmd.drawMarquee(dchars,strlen(dchars),(32*DISPLAYS_ACROSS)-1,0);
long start=millis();
long timer=start;
boolean ret=false;
while(!ret){
if ((timer+30) < millis()){
ret=dmd.stepMarquee(-1,0);
timer=millis();
}
}
}
}
void serialEvent(){
while(Serial.available())
{
char ch=(char)Serial.read();
str[i++]=ch;
if(ch == '*')
{
temp=1;
}
}
}
The DMD library was found on the net.