sms message to scrolling dot matrix

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

i am using the following code to show and scroll messages on my led dot matrix. it uses the serial monitor as input device:

So, figure out which parts are which. Some part is collecting the data to display. Some part is storing the data. Some part is displaying the data. Once you know which part is which, changing the source of the data is trivial.

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.

Nor do we, since you provided no proof that you can (sometimes) receive messages. Nor did you explain what "weird stuff happens".

your post is not helpful at all, but thank you anyway for your time

as to the "proof of recieval" you requested:
well, as i explained, the code for recieving messages is recieving messages, as suggested by the arduino tutorial to "recieve messages" and i have tested that part and it actually recieves messages, as i have said. so much for that part.

the problem is, that the other code for sending characters to the led dot matrix is waiting for a serial input to send to the matrix, which in this case is not happening if a sms message is sent and printed in the serial port.

and as i have also mentioned, the reason why im writing this is because i am not good at programming. and if you have anything constructive to contribute on how to make the content of a sms message recieved by the gsm shield being injected to the serial monitor (as if i would write it manually), it would be much appreciated.

thank you in advance!

your post is not helpful at all,

I think you should be posting in Gigs and Collaboration, and offering to pay someone, since you seem not at all interested in actually learning to program. Good luck, anyway.

and how am i suposed to learn if there is no teacher ?
ive been stuck with this problem for days and did a lot of research and of course tried to understand the code but failed. but if you only answer questions if you get paid you should probably call this forum "programming questions -(anwers only for money)"

and how am i suposed to learn if there is no teacher ?

Google.
Get a book.
Take a class.
Add print statements.
Look at the reference material.
Ask questions. If you don't understand what some code does, ask.

But, really, tell me this. If you aren't a programmer, and aren't willing to learn (on your own, if need be), why are you doing this project?

and of course tried to understand the code but failed.

There was no clue in your posted that even hinted at this. If you had put comments in the code, like
// I think this is ...
then, we could have compared the code and the comments, to confirm that you understand it, or explain what the code actually does, if you're understanding was wrong.

am using the following code to show and scroll messages on my led dot matrix. it uses the serial monitor as input device:

  // New character received from Serial?
  if (Serial.available() > 0) {

Correct.

    // Read incoming character
    char incoming_char = Serial.read();
    
    // End of line?
    if(incoming_char == '\n') {

Yes and yes.

      // Add string terminator to rx buffer
      text_buffer[text_position] = '\0';
      
      // Copy received string
      strcpy(display_string, text_buffer);

And this IS where the serial data that has arrived is copied to display_string. The name itself should have been a big enough clue.

And THAT is where the fact that data comes from the serial port ceases to be relevant. You can follow that outline, and the else block that follows, to get data from your cell phone instead. Notice that the structure of the code that reads from the phone is VERY similar. See if there is data to read. If there is, read the data.

Notice that NOTHING happens with the character that you read from the phone, whereas there IS something happening with the data that is read from the serial port.

Notice, too, that there is NOTHING different about the data. A character is a character.

only answer questions if you get paid you should probably call this forum "programming questions -(anwers only for money)"

No. This forum is for providing answers to the "How do I..." and "What does this do..." and "What is wrong..." type of questions FOR FREE. The "Will you write my code for me" questions belong in Gigs and Collaboration, where help may not be free.

thanks very much for the hints and help!
i apologize for my first reactions. i was new to the forums and desperate and should have expressed myself and the problem in a different way.

 // 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);

if i understand it correctly this part of the code is checking if there is a new character available at the serial port and if there is, it saves it in a temporary variable which is completet if it recieves a "\n" (end of line) and then copied as a string in the text buffer in order to be sent to the matrix.

now my approach to get the characters of another input instead of the serial would be the following: including the arduino gsm library i have access to a function which is called "GSM_SMS.read" for the sms class, which is similar to the serial class (at least concerning the .read and .available function) Now instead of cheking if there is a new character at the serial port

 // New character received from Serial?
  if (Serial.available() > 0) {

i would check if there is a new character of a sms availabel

if (sms.available() > 0) {

and instead of saving the new character of the serial into a temporary variable i save the character of the sms

// Read incoming character
    char incoming_char = sms.read();

i thought this should do the magic but nothing happens at all.
am i missing something ?
by the way "sms" is the "GSM_SMS" class in my sketch.

thanks in advance !
jul

This statement:

    char incoming_char = sms.read();

is the correct replacement for:

    char incoming_char = Serial.read();

But, you still need to store the incoming characters in an array, until the correct message terminator arrives.