Array to Strings

First I would like to say that I have looked this up in Google but I guess I either don’t understand the problem well enough or the answers are not for my specific instance of the problem…
I am just trying to take serial input and add the value to the sMessage string.

int i, MessageLength, Message[10];

void setup()
{
Serial.begin(115200);
}
void loop()
{
  String Smessage(Message);
  if(Serial.read() == '

Can someone lead me in the direction of what I am doing wrong??)
  {
    for(i=0; i<10; i++)
    {
    delay(1);
    Message[i] = Serial.read();
    if(Message[i]==’/’)
    break;
    }
MessageLength = i;
for(i=0; i<MessageLength; i++)
  {
  Serial.print(char(Message[i])); 
  }
Serial.print(Smessage);
}


Can someone lead me in the direction of what I am doing wrong??

The only two things you are doing right are using setup() and loop()

Never use String it just wastes memory.

Ensure that you use the correct type Message should be char not int.

Never assume that the whole of a message available.

Assuming your message starts with a $ and end with /. Read and throw away chars until the $

Then read and store the chars in message until the /

Use an FSM (look in the playground) to deal with the above and the fact that most of the time where will be nothing to read.

After that as your using string (array of char) and not String there is no conversion issue!

Mark

Further to what holmes4 just said, look up Serial.available() and it's usage example.

Per OldSteve: https://www.arduino.cc/en/Serial/Available