So I am very new to Arduino and a beginner programmer at best. That said, I am having a similar problem nend in the original post.
-Arduino Mega 2560
-I/O Expansion shield, for Serial-RS485 communication
-Displacement Laser, communicates of RS485
-SD Card Logger Shield
What I am trying to do:
-Send a command over RS485 to the Displacement Laser asking for a measurement, this is working already
. Nine (9) characters and a carriage return.
Should (and does) look like this: %01#RMD**\r
-Receive the measurement (a character string) from the Displacement Laser, again over RS485, I am not sure if this is working yet
. Seventeen (17) characters and a carriage return.
Should look something like this: %01$RMD-0142901**
-Display the measurement optimally as just a number and not the character string (I am willing to take baby steps) onto the LCD 4884.
On the screen it should look something like: -14.2901 mm or %01$RMD-0142901** would be acceptable
So far all the screen displays is: ~'
I know how to display text and a regular variable, but apparently its not the same as a serially read variable
-Write/append each new measurement value to a file on the SD card/Logger Shield. Have not yet gotten this far.
My Code (partly self written, partly from examples far-and-wide on the Internet, partly from this forum post (nend and olikraus), I am ignoring the SD card for the meantime:
int EN = 20; //RS485 TX/RX enable pin
int x = 0;
char inputStr = 0;
//Included files for LCD4884
lcd.LCD_init(); // creates instance of LCD
lcd.LCD_clear(); // blanks the display
// Enable Data Transfer
// Ask for Displacement over RS485 (Serial1)
// Enable Data Recieve
// Recieve Value over RS485 (Serial)
inputStr = Serial1.read();
// Convert Serial1 Value
string = inputStr;
string = '\0';
// Display Serial1 Value on LCD4884
Help is much appreciated!