0

I am trying to turn an LED on/off by using GSM 808 module. Here #a0 = LED off and #a1 = LED on. I have used lcdShow function to display characters in LCD display. But nothing appears on display. What is wrong in this code?

#include <SoftwareSerial.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
//I2C pins declaration
LiquidCrystal_I2C lcd (0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
SoftwareSerial SIM808 (10, 11);
char inchar;
const int LED = 2;
void setup ()
{
 Serial.begin (9600);
 SIM808.begin (9600);
 delay (10000);
 SIM808.print ("AT+CMGF=1\r");
 delay (100);
 SIM808.print ("AT+CNMI = 2,2,0,0,0\r");
 delay (100);
 lcd.begin (16, 2);
 lcd.backlight ();
 delay (1000);
 pinMode (LED, OUTPUT);
 digitalWrite (LED, HIGH);
}
void loop ()
{
 if (SIM808.available () > 0)
 {
 inchar = SIM808.read ();
 if (inchar == '#')
 {
 lcdShow (inchar);
 delay (10);
 inchar = SIM808.read ();
 if (inchar == 'a')
 {
 lcdShow (inchar);
 delay (10);
 inchar = SIM808.read ();
 if (inchar == '0')
 {
 lcdShow (inchar);
 digitalWrite (LED, LOW);
 }
 else if (inchar == '1')
 {
 lcdShow (inchar);
 digitalWrite (LED, HIGH);
 }
 }
 }
 SIM808.println ("AT+CMGD = 1,4");
 }
}
void lcdShow (char i)
{
 lcd.setCursor (0, 0);
 lcd.print (i);
 delay (5000);
}
Code Gorilla
5,6521 gold badge17 silver badges31 bronze badges
asked Aug 6, 2018 at 6:19

1 Answer 1

-1

Firstly your code was really poorly formatted, making it difficult to see what it did.

After reformatting my best guess as to why you LCD is blank is that the SIM808 is does not have any data available. print something in the else statement.

Next it could be that the LCD is not working, print something out in setup().

You might also want to add a delay to loop() to prevent the Arduino spamming your SIM808.

answered Aug 7, 2018 at 11:59

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.