Go Down

Topic: Question about send a string usind println (Arduino simulation) (Read 414 times) previous topic - next topic

seth9008

Oct 09, 2013, 04:22 am Last Edit: Oct 09, 2013, 04:24 am by seth9008 Reason: 1
Hi, i'm develping Android apps with bluetooth support for use it with bluetooth modules (bluetooth serial modules like HC-05).

I'm testing my apps. I simulate the circuits (arduino+serial port) because i haven't a bluetooth module.

Now i have a problem. Using a serial monitor (Octoplus Terminal) and use the virtual serial port of my bluetooth dongle (bluetooth usb dongle) and connecting it to android device i can send and recieve data normally.

But, when i use proteus to simulate arduino + serial port (COMPIM) i have problems receiving data. In arduino i send a string when a led turn on "Led ON", but in the android app only can receive the last character, well, it receive all characters of the string, but the android device take character per character (each character of string is taked by android like a string)

I have tested all Serial Monitors that i know and in all of them the data transfer works rigth (i recieve full strings), but when i simule arduino i can't recieve  the full string.....

With monitors data transfer i recieve Led On (the text showed is Led On)

simulating arduino I recieve

L
e
d

o
n

(the last character showed is, in this case n)

it could be for be a simulation?...or i need to change the format of text i send?

the code of arduino:

String str = "";
char dato;

void setup()
{
  pinMode(13,OUTPUT);
  Serial.begin(9600);
}

void loop()
{
 
  while(Serial.available())
  {

      dato= Serial.read();
     
      switch(dato)
      {
        case '1':
        {
          digitalWrite(13,HIGH);
          str = "Led On";
          break;
        }
        case '2':
        {
          digitalWrite(13,LOW);
          str = "Led OFF";
         
          break;
        }
        case 'r':
        {
          digitalWrite(13,HIGH);
          delay(200);
          digitalWrite(13,LOW);
          delay(200);
          digitalWrite(13,HIGH);
          delay(100);
          digitalWrite(13,LOW);
          delay(100);
          str="Blink Led";
          break;
        }
      }  
      Serial.print(str);  
  }
}

Go Up