Bonjour
Dans le cadre d'un projet avec un shield SIM900 j'aimerai afficher les messages SMS reçus sur un écran LCD (20x4).
J'ai pas encore testé mais a priori si le message est trop long (plus de 20 caractères) j'imagine que le message sera coupé.
Est-il possible de faire en sorte que le saut de ligne se fasse automatiquement ?
le code :
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,20,4);
/*********
Complete project details at http://randomnerdtutorials.com
*********/
#include <SoftwareSerial.h>
// Configure software serial port
SoftwareSerial SIM900(7, 8);
//Variable to save incoming SMS characters
char incoming_char=0;
void setup() {
lcd.begin(20,4);
// Arduino communicates with SIM900 GSM shield at a baud rate of 19200
// Make sure that corresponds to the baud rate of your module
SIM900.begin(19200);
// For serial monitor
Serial.begin(19200);
// Give time to your GSM shield log on to network
delay(20000);
// AT command to set SIM900 to SMS mode
SIM900.print("AT+CMGF=1\r");
delay(100);
// Set module to send SMS data to serial out upon receipt
SIM900.print("AT+CNMI=2,2,0,0,0\r");
delay(100);
}
void loop() {
// Display any text that the GSM shield sends out on the serial monitor
if(SIM900.available() >0) {
//Get the character from the cellular serial port
incoming_char=SIM900.read();
//Print the incoming character to the terminal
Serial.print(incoming_char);
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(incoming_char);
delay(10000);
}
}