Hello all - I'm quite new to Arduino programming and am having issues with datatypes, concatenating values and Serial.write. My project will read the values from a joystick and send the values via an xbee to a robot, receiving it via another xbee. My goal is to read the values of the joystick, concatenate the 3 values into a string, and send that value to my robot.
When I send a test string to the robot such as:
Serial.print("600 601 602"); Serial.write("\n");
The receiving code is able to successfully extract the 3 numbers.
My issue is how to use the proper data types and concatenation to read the joystick values and send a similarly formatted value to "Serial.print". The following code seems to convert the numbers into their ascii values
// Serial.print(analogRead(0)); //Read the position of the joysticks X axis and print it on the serial port // Serial.print(" "); // Serial.print(analogRead(1)); //Read the position of the joysticks Y axis and print it on the serial port // Serial.print(" "); // Serial.print(digitalRead(8)); //Read the position of the select button and print it on the serial port // Serial.print("\n");
So my question, poorly worded, is how do I read the 3 values and send it in the same format as my testing sample above?
Thanks for any help or direction,