 int motorPinA2 = 9;    // Pink   - 28BYJ48 pin 2
 int motorPinA3 = 10;    // Yellow - 28BYJ48 pin 3
 int motorPinA4 = 11;    // Orange - 28BYJ48 pin 4
-
+int motorSpeedA = 1200;
+int motorStepRevA = 512; //steps per full rev
+int lookupA[8] = {B01000, B01100, B00100, B00110, B00010, B00011, B00001, B01001};
+//How many steps stepperA has taken. for counting how much degrees to reset
+int stepperA = 0;
 // The setup() method runs once, when the sketch starts
-
 void setup()   {                
   // initialize the IR digital pin as an output:
   pinMode(IRledPin, OUTPUT);      

void loop()                     
{
  byte inputCommand;
  
  if (Serial.available()) {
    Serial.println("Sending IR signal");
    inputCommand = Serial.read();
    Serial.println(inputCommand);
    switch (inputCommand) {
      case 67:
      Serial.write('Mute');
      SendMuteCode();
      case 117:
      Serial.write('0');
      SendOnCode();
      break;
      case 118:
      Serial.write('0');
      SendOnCode();
      break;
      case 119:
      Serial.write('1');
      SendChannelUpCode();
      break;
      case 120:
      Serial.write('2');
      SendChannelDownCode();
      break;
      case 121:
      Serial.write('3');
      SendVolUpCode();
      delay(300);
      SendVolUpCode();
      delay(250);
      SendVolUpCode();
      delay(250);
      SendVolUpCode();
      delay(250);
      SendVolUpCode();
      delay(250);
      SendVolUpCode();
      break;
      case 122:
      Serial.write('4');
      SendVolDownCode();
      delay(300);
      SendVolDownCode();
      delay(250);
      SendVolDownCode();
      delay(250);
      SendVolDownCode();
      delay(250);
      SendVolDownCode();
      delay(250);
      SendVolDownCode();
      break;
      case 123:
      Serial.write('5');
      SendChannel59Code();
      break;

    }


pulseIR(8820);
delayMicroseconds(2160);
pulseIR(600);
}

void turnResetCode() {
  while (stepperA > 0) {
    for (int i = 0; i < 8; i++) {
      setOutputA(i);
      delayMicroseconds(motorSpeedA);
    }
  stepperA--;
  }
}

void turnCode(int steps) {
  while (stepperA <= steps) {
    for (int i = 7; i >= 0; i--) {
      setOutputA(i);
      delayMicroseconds(motorSpeedA);
    }
  stepperA++;
  }
}

void setOutputA(int out) {
  digitalWrite(motorPinA1, bitRead(lookupA[out], 0));
  digitalWrite(motorPinA2, bitRead(lookupA[out], 1));
  digitalWrite(motorPinA3, bitRead(lookupA[out], 2));
  digitalWrite(motorPinA4, bitRead(lookupA[out], 3));
}
