Reading serial string data from arduino in processing and storing as string variable

edited February 2014 in Arduino

Dear friends,

Through the following arduino program , I am sending float lat , lng values in string form through arduino serial port, sequentially . This program is working successfully.

String lat="17.372651",lng="78.552167";

void setup() {

Serial.begin(9600);

}

void loop() { Serial.print("lat"); delay(1000); Serial.print(lat); delay(1000); Serial.print("lng"); delay(1000); Serial.print(lng); delay(4000); }

The values of lat and lng , are displayed sequentially in arduino IDE serial monitor.

Through the following processing program, I am able see those values sequentially in processing console window.

import processing.serial.*; String inBuffer,lat,lng,temp; int portIndex = 4; Serial myPort;

void setup() { println(Serial.list()); myPort = new Serial(this, Serial.list()[portIndex], 9600); }

void draw() { while (myPort.available() > 0) { inBuffer = myPort.readString(); if (inBuffer != null) { temp=inBuffer; print(temp); }
}

}

But I like to read and store those values as string variables and use them further in my program. Can you give me the way?

K.Sitarama Rao, Electronics Engineer and Hobbyist.

Comments

Sign In or Register to comment.