 int pos = 0;    // variable to store the servo position
 
 void setup() {
+  //Start the serial, which is vital to communicating with the computer
   Serial.begin(9600);
   
   

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
Servo s2;
Servo s3;
Servo s4;
Servo s5;
// twelve servo objects can be created on most boards
int letters[27][5]{
  //a
  {180,180,180,180,0},



void loop() {
  //Check if the serial has sent a letter then...
  if (Serial.available() > 0){
    //...read that letter...
    String string = Serial.readString();
    //...Convert it into a string for use with the array...
    number = string.toInt();
    //...And call the function that sets the hand position
    callletter(number);
    delay(1000);
  }
}
//Set the hand position
void callletter(int letter){
    
    letter = letter - 1;
    //End serial so I can connect to servos
    Serial.println(letter);
    Serial.end();
    //Attach servos
    myservo.attach(9,0,letters[letter][0]);  
    s2.attach(11,0,letters[letter][1]);
    s3.attach(10,0,letters[letter][2]);
    s4.attach(6,0,letters[letter][3]);
    s5.attach(5,0,letters[letter][4]);
    //Write the position to servos
    for (pos = 0; pos <= letters[letter][0]; pos += 1) {
      myservo.write(pos);
      
    }
    for (pos = 0; pos <= letters[letter][1]; pos += 1) {
      s2.write(pos);
    }
    for (pos = 0; pos <= letters[letter][2]; pos += 1) {
      s3.write(pos);
    }
    for (pos = 0; pos <= letters[letter][3]; pos += 1) {
      s4.write(pos);
    }
    for (pos = 0; pos <= letters[letter][4]; pos += 1) {
      s5.write(pos);
    }
    delay(500);
    //detach servos so serial can reconnect
    myservo.detach(); 
    s2.detach();
    s3.detach();
    s4.detach();
    s5.detach();
    //Reconnect serial
    Serial.begin(9600);
}

