Arduino freeze when declare String variable

Discussion in 'Arduino IDE' started by y.seksit, May 9, 2014.

  1. y.seksit

    y.seksit New Member

    Joined:
    May 8, 2014
    Messages:
    17
    Likes Received:
    0
    Simple program with String variable will make Arduino freeze, source code like below

    void loop()
    {
    String myStr = "";
    }
     
  2. peter247

    peter247 Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    How do you know it`s freezing with your code , it`s not doing anything .
     
  3. y.seksit

    y.seksit New Member

    Joined:
    May 8, 2014
    Messages:
    17
    Likes Received:
    0
    My code like below, Due freeze when i comment variable String recv = "", when I change it to Charactor array like char recv[200];, code will work fine,

    String recv = "";

    void setup(){
    Serial.begin(9600);
    }

    void loop(){
    while (Serial.available())
    {
    char ch = Serial.read();
    recv += ch;
    if (ch = '\n') {
    Serial.println(recv);
    }
    }
     
  4. Simsy

    Simsy New Member

    Joined:
    Jan 12, 2015
    Messages:
    7
    Likes Received:
    0
    Hi, I've got a similar issue with the Due freezing when certain code is included. Did you manage to get to the bottom of what was going on with your issue ?
     

Share This Page