Sending strings to control servos


can someone please advise how we can send strings over a serial command to the arduino?

is there a way to just serially pass 1023 instead of having to send a character....

Yes you can send anything you like including "1023" to the arduino but it means you have to assemble the number from the individual characters send. You can do this yourself or use a library like This is a quite powerful library especially handy if your program grows.

If done yourself you should have some code like: int x = 0; and something like x = x * 10 + (int) (Serial.Read() - '0'); in a loop to collect the digits and make a integer out of it.

Please don't change the question, add additional questions is more appropiate.

can someone please advise how we can send strings over a serial command to the arduino?

Read and use the Serial monitor in the IDE as the interface on your PC.

Thanks :) I'll look into it!

The read() function only allows us to read bytes...not strings...

Yes and a string is a string of bytes /characters so you just have to add them together yourself.

i tried to import the messenger library but it's not being recognised by my IDE :-?

....any suggestions?

To add a library you must place it in a directory named libraries in your sketchbook folder (see file> preferences menu for location). Other location can be in the arduino/libraries folder but the first one is preferred. You also need to restart the IDE as it reads the libraries at startup.

See also:

Below is some code I use for tesing my servos:

// zoomkat 10-4-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// for IDE 0019 and later
// Powering a servo from the arduino usually DOES NOT WORK.

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {
  myservo.attach(7);  //the pin for the servo control 
  Serial.println("servo-test-21"); // so I can keep track of what is loaded

void loop() {

  while (Serial.available()) {
    if (Serial.available() >0) {
      char c =;  //gets one byte from serial buffer
      readString += c; //makes the string readString

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 
    int n;
    char carray[6]; //converting string to number
    readString.toCharArray(carray, sizeof(carray));
    n = atoi(carray); 
    myservo.writeMicroseconds(n); // for microseconds
    //myservo.write(n); //for degees 0-180