I am trying to use a Raspberry Pi to control a ESC and for that I am sending the instructions for the ESC using serial. My problem is that when i send the instructions i can not interoperate them, and by interoperate I mean check what the first letter is and then remove it and make the Arduino output a PWM signal. My problem is when I use the serial monitor to send an instruction it firstly comes up on several lines, and when I try and look at the first letter of the string the if statement thinks it is true for all inputs of "FirstLetter" my function to get the serial input it
String readSerial()
{
char SerialInput;
String Data = "";
if (Serial.available())
{
SerialInput = Serial.read();
Data.concat(SerialInput);
//Serial.println(Data);
}
return Data;
}
the function that should interoperate the information from readSerial() is
void DecodeInput()
{
String input = readSerial();
if (input != "")
{
char FirstLetter = input.charAt(1);
if (FirstLetter = 'U')
{
Serial.println("Hello World");
//input.setCharAt[0, '');
//SetPower('U', Power);
}