hello and good day everybody!
i have following problem and hope someone might be able to help.
i am using the following code to show and scroll messages on my led dot matrix. it uses the serial monitor as input device:
void loop() {
long current_millis = millis();
// Time to scroll?
if(current_millis - previous_millis > SCROLLING_SPEED) {
previous_millis = current_millis;
scroll();
// New character received from Serial?
if (Serial.available() > 0) {
// Read incoming character
char incoming_char = Serial.read();
// End of line?
if(incoming_char == '\n') {
// Add string terminator to rx buffer
text_buffer[text_position] = '\0';
// Copy received string
strcpy(display_string, text_buffer);
// initialize variables
text_position = 0;
letter_position = 0;
column_position = 0;
buffer_position = 0;
get_letter_variables();
actual_state = S_LETTER;
// clear buffer
for(int i = 0; i < 32; i++) display_buffer[i] = 0x00;
Serial.print("Now displaying: ");
Serial.println(display_string);
}
// Normal character? Save it in rx buffer
else if(text_position < TEXT_BUFFER_SIZE - 2) {
text_buffer[text_position] = incoming_char;
text_position++;
}
// End of buffer reached? Restart from 0
else {
text_buffer[0] = incoming_char;
text_position = 1;
}
}
}
now my problem is, i have absolutley no clue how to send the content of an recieved sms message from the arduino gsm shield to the serial port and show that on the led dot matrix.
i tried combining it in a lot of different ways with the code provided by the "recieve sms message tutorial" on the arduino gsm shield, but either nothing or some weird stuff happens. im still a beginner in programming and i have absolutley no clue what i am missing.
here is the "recieve sms messge onarduino gsm module" code:
// libraries
#include <GSM.h>
// PIN Number
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;
char remoteNumber[20]; // Holds the emitting number
void setup()
{
// initialize serial communications
Serial.begin(57600);
Serial.println("Bottleneck");
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop()
{
char c;
// If there are any SMSs available()
if (sms.available())
{
// Read message bytes and print them
while(c=sms.read())
Serial.print(c);
Serial.println("\n");
// delete message from modem memory
sms.flush();
}
delay(1000);
}
my code is now somehow a mixture of the two, but there is a missing link:
// libraries
#include <GSM.h>
// PIN Number
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;
char remoteNumber[20]; // Holds the emitting number
void setup()
{
// initialize serial communications
Serial.begin(57600);
Serial.println("Bottleneck");
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop()
{
char c;
// If there are any SMSs available()
if (sms.available())
{
// Read message bytes and print them
while(c=sms.read())
Serial.print(c);
Serial.println("\n");
// delete message from modem memory
sms.flush();
}
delay(1000);
}
i know that the problem lies somewhere betwenn the lines:
while(c=sms.read())
Serial.write(c);
and the serial.available check of the old code, but i am really stuck.
any help would be much apreciated!
thank you a lot in advance!
ahoi,
jul