Hi All.
I am reading data sent from a a PC over the serial port and I am getting the expected output on the LCD compared to what my comport scanner tells me and what the PC Satellite Tracking software tells me.
The message arrives in this format:
W123 021||
The W represents the command that the manufacturers original PIC read to activate the motor in a particular mode. W being, step to these degrees and elevation on Serial.read.
The first set of 3 numbers is degrees of the compass.
The second set of 3 numbers is degrees of elevation.
Then there is two (carriage returns?)
There is no space after the W, there is no space after the last third digit. There is a space in between the numbers
So,
Wxxx xxx||
An emergency stop command can also be sent which is a single C character.
My Question therefore is....
Is there a way to use a mask or a special way to read the int values and separate them into, for instance, DEGROTATION, DEGELEVATION ?
Thanks in advance.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Rotator Software");
delay(1000);
lcd.setCursor(0,0);
delay(1000);
}
void loop() {
if(Serial.available()){
lcd.setCursor(0, 1);
lcd.print(" ");
delay(100);
lcd.setCursor(0, 1);
while(Serial.available() > 0){
lcd.write(Serial.read());
}
}
}