String inputstring = ""; //a string to hold incoming data from the PCString sensorstring = ""; //a string to hold the data from the Atlas Scientific productboolean input_stringcomplete = false; //have we received all the data from the PCboolean sensor_stringcomplete = false; //have we received all the data from the Atlas Scientific product

void serialEvent() { //if the hardware serial port receives a char char inchar = (char)Serial.read(); //get the char we just received inputstring += inchar; //add it to the inputString if(inchar == '\r') {input_stringcomplete = true;} //if the incoming character is a <CR>, set the flag }

void loop(){ //here we go....

if (input_stringcomplete){ //if a string from the PC has been recived in its entierty myserial.print(inputstring); //send that string to the Atlas Scientific product inputstring = ""; //clear the string: input_stringcomplete = false; //reset the flage used to tell if we have recived a completed string from the PC }

while (myserial.available()) { //while a char is holding in the serial buffer char inchar = (char)myserial.read(); //get the new char sensorstring += inchar; //add it to the sensorString if (inchar == '\r') {sensor_stringcomplete = true;} //if the incoming character is a <CR>, set the flag }

if (sensor_stringcomplete){ //if a string from the Atlas Scientific product has been received in its entirety Serial.print(sensorstring); //use the hardware serial port to send that data to the PC sensorstring = ""; //clear the string: sensor_stringcomplete = false; //reset the flag used to tell if we have received a completed string from the Atlas Scientific product }}

provided it is an integer and not a number with a decimal point in it, this might work.if you like your strings to be simple character arrays, use Cif you like your strings to be objects, use JavaDealing with both can be a real pain in the neck.

void setup(){ pinMode(ledpin, OUTPUT); // pin 13 (on-board LED) as OUTPUT pinMode(Mopen, OUTPUT); // pin Mopen is set as an output pinMode(Mclosed, OUTPUT); // pin Mclosed is set as an output pinMode(M1L, OUTPUT); //pin MIL is set as an output pinMode(M1R, OUTPUT); // in MIR is set as an output pinMode(M2L, OUTPUT); //pin M2L is set as an output pinMode(M2R, OUTPUT); // pin M2R is set as an output Serial.begin(9600); // start serial communication at 115200bps

}

void loop() { if( Serial.available()) // if data is available to read, this is how to check the serial part for strings { digitalWrite(ledpin, HIGH); // if data is detected set the pint set to ledpin to HIGH (ON) char c= Serial.read(); // the string in serial read() is buffered in to c as characters if (c == ','){ //look at the incoming chars, if it is a ',' then switch the case currentCommand++; //for some reason currentCommand increments???? } else { //if it is not ',' then store chars in string, keep storing the string until a , is found val += c; // same as (val + c = c)val is the next string + the previous character stored in buffer //Serial.println(val); switch (currentCommand) { // for each string, currentCommand appears to increment by 1

case 0: //in the even there was only 1 string before the ',' X is equal to the val in buffer and val buffer is cleared "" X += val; // same as (X + val = val), new variable X is equal to the whole string val before the ',' val = ""; // clear the information in the val buffer break; // break out of case 0

if (c == ','){ //look at the incoming chars, if it is a ',' then switch the case currentCommand++; //for some reason currentCommand increments???? }If the character is a deliminator (comma in this case) increment the number of commands received.

else { //if it is not ',' then store chars in string, keep storing the string until a , is found val += c; // same as (val + c = c)val is the next string + the previous character stored in buffer //Serial.println(val);If it's not a comma, concatenate it onto the String val (note the difference in capitalization, String and string are not the same thing).

Its not needed, you can take it out. I originally wrote this code using a C++ based debugger software (old software), and it had to be inserted at the top. so when I brought it to arduino, I forgot to take it out.

Quote

move(x, y, s); // DO NOT UNDERSTAND "move()"

Move() is a function I made that feeds those gotten values to my motors, it is get rid of too much cluster in my Loop function.

It is very difficult to modify code on an IPhone, so I just left everything in. I just wanted to show you an example of how to get, convert and split the data to different ints.

And they are not servos, they are DC motors. However same can be done with servos.

Thanks Arrch, I would like convert this into a floating number but I'm having a hard time finding the Reference syntax in Arduino for the following C equivalents? Would you happen to know where I can find them?