#include #define txPin 9 // PA0(MISO) transmit signal to the bridge #define rxPin 8 // PA1(SCK) recieves signal from bridge SoftwareSerial mySerial(rxPin, txPin); const int stepPin = 17; const int dirPin = 18; const int stepPin2 = 14; const int dirPin2 = 15; char Incoming_value = 0; //Variable for storing Incoming_value void setup() { mySerial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission pinMode(txPin, INPUT); //default tx as input pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); pinMode(stepPin2, OUTPUT); pinMode(dirPin2, OUTPUT); } void loop() { if (mySerial.available() > 0) { Incoming_value = mySerial.read(); //Read the incoming data and store it into variable Incoming_value mySerial.print(Incoming_value); //Print Value of Incoming_value in Serial monitor mySerial.print("\n"); //New line if (Incoming_value == 'A') { digitalWrite(dirPin, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 100; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'a') { digitalWrite(dirPin, HIGH); for (int x = 0; x < 100; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'B') { digitalWrite(dirPin, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 200; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'b') { digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 200; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'C') { digitalWrite(dirPin, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 300; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'c') { digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 300; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'D') { digitalWrite(dirPin, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 400; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'd') { digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 400; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'E') { digitalWrite(dirPin, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 500; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'e') { digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 500; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'F') { digitalWrite(dirPin, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 600; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'f') { digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 600; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'G') { digitalWrite(dirPin, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 700; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'g') { digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 700; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'H') { digitalWrite(dirPin, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 800; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'h') { digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 800; x++) { digitalWrite(stepPin, HIGH); delay(1); // ms digitalWrite(stepPin, LOW); delay(1); } } if (Incoming_value == 'I') { digitalWrite(dirPin2, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 100; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'i') { digitalWrite(dirPin2, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 100; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'J') { digitalWrite(dirPin2, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 200; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'j') { digitalWrite(dirPin2, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 200; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'K') { digitalWrite(dirPin2, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 300; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'k') { digitalWrite(dirPin2, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 300; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'L') { digitalWrite(dirPin2, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 400; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'l') digitalWrite(dirPin2, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 400; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'M') { digitalWrite(dirPin2, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 500; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'm') { digitalWrite(dirPin2, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 500; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'N') { digitalWrite(dirPin2, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 600; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'n') { digitalWrite(dirPin2, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 600; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'O') { digitalWrite(dirPin2, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 700; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'o') { digitalWrite(dirPin2, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 700; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'P') { digitalWrite(dirPin2, LOW); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 800; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } if (Incoming_value == 'p') { digitalWrite(dirPin2, HIGH); // Enables the motor to move in a particular direction // Makes 800 pulses for making one full cycle rotation for (int x = 0; x < 800; x++) { digitalWrite(stepPin2, HIGH); delay(1); // ms digitalWrite(stepPin2, LOW); delay(1); } } } }