My objective is: Whenever a SMS is sent to the SIM300 GSM module, that message should be displayed on the LCD using Arduino. I am using Arduino Leonardo. But I am unable to code it properly. So I am in great need of your help and suggestions. Please tell me the proper code for the above objective.
Regards.
Please post the code you have written - it's easier to help you that way.
This is what I have..
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
// give the pin a name:
int led = 9;
// incoming serial byte
int inByte = 0;
void setup()
{
pinMode(9, OUTPUT);
lcd.begin(16, 2);
lcd.print("ENGINEERS GARAGE");
lcd.setCursor(0, 1);
lcd.print(" GSM SMS ");
delay(1000);
// initialize the led pin as an output.
pinMode(led, OUTPUT);
// start serial port at 9600 bps
Serial.begin(9600);
// wait for a while till the serial port is ready
delay(100);
// send the initial data once //
Serial.print("AT+CMGF=1\n\r");
delay(500);
Serial.print("AT+CNMI=2,2,0,0,0\n\r");
delay(2000);
digitalWrite(led, HIGH);
}
void loop()
{
do
{
while ( !Serial.available() );
} while ( '"' != Serial.read() );
do
{
while ( !Serial.available() );
} while ( '"' != Serial.read() );
do
{
while ( !Serial.available() );
} while ( '"' != Serial.read() );
do
{
while ( !Serial.available() );
} while ( '"' != Serial.read() );
while ( !Serial.available() );
inByte = Serial.read();
while ( !Serial.available() );
inByte = Serial.read();
lcd.clear();
while(1)
{
while ( !Serial.available() );
inByte = Serial.read();
if ( inByte == '\r' )
break;
else;
lcd.write ( inByte );
}
}
Plz post a better code if you have or else help me in modifying this one
I'm not going to fix. your code. Read some of the links I gave you and maybe you will learn what you are doing wrong.
A link to the particular shield you are using wouldn't go amiss either.
click the MODIFY button in the upper right of the post window.
Highlight all you code.
click the "#" CODE TAGS button on the toolbar above just to the left of the QUOTE button.
click SAVE (at the bottom).
When you post code on the forum, please make a habit of using the code tags "#" button.