I'm currently using an Opti-Logic RS400 Laser Range Finder along with an Arduino MEGA 2560 for a project. I've been trying to read the serial data using code I've found online, but what I get back is gibberish because I don't know how to properly filter or convert the data. I've tried using simple serial reading code like this:
String readString;
void setup() {
Serial.begin(9600);
Serial2.begin(19200);
Serial.println("Serial Test");
}
void loop() {
while (Serial2.available()) {
delay(100);
if (Serial2.available() >0) {
readString = Serial2.read();
readString += c;}
}
if (readString.length() >0) {
Serial.println(readString);
readString="";
}
}
However, this is what I receive in the serial monitor:
Serial Test
?}-¥g!1-9¿[Y???¿[=#153-#75e¿S5e?£?åë'!5¿?¿
When I need to receive something like:
Serial Test
DIST:0046.61F
DIST:0046.42F
DIST:0046.25F
The lrf uses RS-232 serial, and I thought this data could be readily converted with Arduino into string form, but I must be missing several steps. I set the Baud rate to 19200 which is under the specs, but the sensor is a little odd in that the instructions ask me to use HyperTerminal in Windows with specific settings to operate it through Windows. What vital step am I missing?