Need help using Serial port to communicate with motor.

I'm creating a project using Morse code. However, rather than sound or lights, i am creating a device which will mimic a signal light used by sailors. To make this I'm using an old set of blinds, motor shield and a stepper motor to turn the blinds open and close. I have established my code to create the Morse code on the blinds however at its current stage I have to manually write each letter to be spelled out on the blinds in my code. I would like to somehow use the serial port to enter whatever message a user wants and send it to the motor shield. I'm not sure how to go about doing this though so any help would be greatly appreciated.

*disclaimer: I am new at arduino. I know my code is a bit lengthy but I really am not concerned about that at this point.
Here is my code:

int delaylegnth = 15;

void setup() {

//establish motor direction toggle pins
pinMode(12, OUTPUT); //CH A -- HIGH = forwards and LOW = backwards???
pinMode(13, OUTPUT); //CH B -- HIGH = forwards and LOW = backwards???

//establish motor brake pins
pinMode(9, OUTPUT); //brake (disable) CH A
pinMode(8, OUTPUT); //brake (disable) CH B

Serial.begin(9600);

}

void loop(){

a();
delay(2000);

b();
delay(2000);

c();
delay(2000);

d();
delay(2000);

e();
delay(2000);

f();
delay(2000);

g();
delay(2000);

h();
delay(2000);

i();
delay(2000);

j();
delay(2000);

k();
delay(2000);

l();
delay(2000);

m();
delay(2000);

n();
delay(2000);

o();
delay(2000);

p();
delay(2000);

q();
delay(2000);

r();
delay(2000);

s();
delay(2000);

t();
delay(2000);

u();
delay(2000);

v();
delay(2000);

w();
delay(2000);

x();
delay(2000);

y();
delay(2000);

z();
delay(2000);

}
//97
void a(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);
}
//98
void b(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

}
//99
void c(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}
//100
void d(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}

//101
void e(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}

//102
void f(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}

//103
void g(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}
//104
void h(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}

//105
void i(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}

//106
void j(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);
}

//107
void k(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

}

//108
void l(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}

//109
void m(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);
}

//110
void n(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}

//111
void o(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);
}

//112
void p(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

}

//113
void q(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);
}

//114
void r(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}

//115
void s(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}

//116
void t(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);
}

//117
void u (){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);
}

//118
void v(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);
}

//119
void w(){
turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);
}

//120
void x(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);
}

//121
void y(){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);
}

//122
void z (){
turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(3000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);

turn360Clockwise();
delay(1000);

turn360Counter();
delay(1000);
}

// turn 360 degrees counter clockwise
void turn360Counter(){

for(int i=0; i<61; i++){

digitalWrite(9, LOW); //ENABLE CH A
digitalWrite(8, HIGH); //DISABLE CH B

digitalWrite(12, HIGH); //Sets direction of CH A
analogWrite(3, 1023); //Moves CH A

delay(delaylegnth);

digitalWrite(9, HIGH); //DISABLE CH A
digitalWrite(8, LOW); //ENABLE CH B

digitalWrite(13, HIGH); //Sets direction of CH B
analogWrite(11, 1023); //Moves CH B

delay(delaylegnth);

digitalWrite(9, LOW); //ENABLE CH A
digitalWrite(8, HIGH); //DISABLE CH B

digitalWrite(12, LOW); //Sets direction of CH A
analogWrite(3, 1023); //Moves CH A

delay(delaylegnth);

digitalWrite(9, HIGH); //DISABLE CH A
digitalWrite(8, LOW); //ENABLE CH B

digitalWrite(13, LOW); //Sets direction of CH B
analogWrite(11, 1023); //Moves CH B

delay(delaylegnth);
}
}

// turns 360 degrees clockwise

void turn360Clockwise(){

for(int i=0; i<61; i++){

digitalWrite(9, LOW); //ENABLE CH A
digitalWrite(8, HIGH); //DISABLE CH B

digitalWrite(12, HIGH); //Sets direction of CH A
analogWrite(3, 1023); //Moves CH A

delay(delaylegnth);

digitalWrite(9, HIGH); //DISABLE CH A
digitalWrite(8, LOW); //ENABLE CH B

digitalWrite(13, LOW); //Sets direction of CH B
analogWrite(11, 1023); //Moves CH B

delay(delaylegnth);

digitalWrite(9, LOW); //ENABLE CH A
digitalWrite(8, HIGH); //DISABLE CH B

digitalWrite(12, LOW); //Sets direction of CH A
analogWrite(3, 1023); //Moves CH A

delay(delaylegnth);

digitalWrite(9, HIGH); //DISABLE CH A
digitalWrite(8, LOW); //ENABLE CH B

digitalWrite(13, HIGH); //Sets direction of CH B
analogWrite(11, 1023); //Moves CH B

delay(delaylegnth);
}
}

A serial terminal could be used to knock out the characters.
serial.read() that into an array?

Holy cow there has to be a better way.

I'm thinking an array with morse code data for each character and a simple loop.

char morse_data [] = {
   ".--",  // a
   .... etc
   
   }
   

void send_char (char c) {

    char * ptr = & morse_data [c]; // point to first byte in this character's array entry
	
	while (*ptr) {  // do until the NULL byte
		if (*ptr == '.')   // test for a dot 
		   flash_dot();
		else
		   flash_dash();
		ptr++;		//  increment pointer
	}   
}

You could use single bytes for each character and test the bits, but this is more human readable.


Rob