[SOLVED] Use SoftwareSerial data to map a Servo

Yes.

Get rid of this,

And put

int potVal = map(command.toInt(), 0, 1023, 0, 180);
myServo.write(potVal);

Inside of the parseCommand function, replacing whatever was inside.

@nrobinson2000
Like this?

if (readString.length() > 0) // If a string has been read...
{
Serial.println("Received: " + readString); // Send the parsed string to Serial for debugging
parseCommand(readString); // Do something with the string...
readString = ""; // Clear the string
int potVal = map(command.toInt(), 0, 1023, 0, 180);
> myServo.write(potVal);
}

I get an error that says 'command' was not declared in this scope

This is also not necessary.

No, there is a void parseCommand(String command) before setup(). Put it in there, getting rid of the if (command == "foo") stuff.

It works!!! :grinning:
Thanks so much!!! I never would’ve been able to figure that out!!! :grinning: :smile:

1 Like

You’re welcome.

1 Like