Hi folks,
I dug out an old SE T630 phone I had in a drawer and shoved a pre-pay SIM in and have it successfully working using AT commands through serial.
Now what I want is for the Arduino to "parse" the incoming messages. For example, display them on my (20x4 parallel) LCD. Or do something else when it recognises a certain string.
I am a C / programming noob and have built up most of my Arduino code thus far by googling and looking at the Arduino.cc resources, so this challenge came as, well, a bit of a challenge!
I have finally found an example sketch online which seems to do most of what I want, i.e. read serial output and shove it to the LCD.
From here: Displaying Twitter and Weather on your Arduino LCD Screen
I have this, thus far:
#include <LiquidCrystal.h>
#include <wstring.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(4, 5, 6, 7, 8, 9);
void setup() {
lcd.begin(4, 20); // Set the LCD's number of rows and columns
Serial.begin(9600); // Initialize communication with serial(USB) port.
lcd.print("Hello."); // Print welcome message to LCD.
}
int bufferArray[250]; // Our array to store characters arriving from serial port.
int output = 0;
int i = 0;
void loop() {
int count = Serial.available();
if (Serial.available() > -1) {
delay(1000);
for (i=0; i<count ; i++) {
bufferArray[i] = Serial.read(); // Put into array
output = 1; // Show new data has been recieved
}
}
if (output != 0) { // If new bytes have been recieved
int position = 0;
if (bufferArray[0] == '!') { // Print on first line if message begins with '!'
lcd.clear();
lcd.setCursor(0,0);
position = 1;
} else if (bufferArray[0] == '@') { // Print on second line if message begins with '@'
lcd.setCursor(0,1);
position = 1;
} else if (bufferArray[0] == '^') { // Clear screen if message begins with '^'
lcd.clear();
lcd.setCursor(0,0);
position = 1;
} else {
lcd.clear();
lcd.setCursor(0,0);
}
int j;
for (j = position; j < count; j++) {
lcd.write(bufferArray[j]);
}
output = 0; // Don't print on next iteration
memset(bufferArray, 0, count);
count = 0;
}
}
And I don't really need any of the ifs, etc. I just want it to show the AT commands, SMS content etc on the LCD. However when I've tried editing the above, cutting bits out etc, it seems to break it!
Can anyone help me simplify the above code so it's just the 'bare minimum' I can work from? And maybe help out how I may be able to call various functions and do things (let's keep it simple for now and illuminate an LED when I send a text to it with the word "LED" in the body, for example)?
I realise I'm asking quite a lot but some guidance as if I'm a 5 year old would be much appreciated!
Some background info on Sony Ericsson integration:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1290601471/all
Thanks