 /*-----( Import needed libraries )-----*/
-#include <Stepper.h>
+#include <Stepper.h> 
 
-/*-----( Declare Constants, Pin Numbers )-----*/
-//---( Number of steps per revolution of INTERNAL motor in 4-step mode )---
-#define STEPS_PER_MOTOR_REVOLUTION 32   
-
-//---( Steps per OUTPUT SHAFT of gear reduction )---
-#define STEPS_PER_OUTPUT_REVOLUTION 128  // 5  
-
-#define lightPin 0
+#define lightPin 5
 #define laserPin 7
-#define motorDelay 3
-#define laserDelay 5
+#define motorDelay 4
+#define laserDelay 0
 #define threshold 70
 #define motorSpeed 700
+#define stepSize 2
 
 int note9 = 0x61;
 int note8 = 0x63;

}

/* ( THE END ) */


void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  // Nothing  (Stepper Library sets pins as outputs)
  Serial.begin(115200);
  pinMode(laserPin, OUTPUT);
}/*--(end setup )---*/

void parsePosition() {
  switch (stepID) {
  case 1:
    noteOn(0x90, note1, 0x7F);
    break;
  case 2:
    noteOn(0x90, note2, 0x7F);
    break;
  case 3:
    noteOn(0x90, note3, 0x7F);
    break;
  case 4:
    noteOn(0x90, note4, 0x7F);
    break;
  case 5:
    noteOn(0x90, note5, 0x7F);
    break;
  case 6:
    noteOn(0x90, note6, 0x7F);
    break;
  case 7:
    noteOn(0x90, note7, 0x7F);
    break;
  case 8:
    noteOn(0x90, note8, 0x7F);
    break;
  default:
    noteOn(0x90, note1, 0x00);
    break;
  }
}       

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  for (int i = 1; i < 8; i++) {
    digitalWrite(laserPin, LOW);
    small_stepper.setSpeed(motorSpeed);
    small_stepper.step(stepSize);
    stepID = i;
    delay(motorDelay);
    digitalWrite(laserPin, HIGH);
    delay(laserDelay);
    light = analogRead(lightPin);
    //    if (light > threshold) {
    //      parsePosition();
    //    } else {
    //      noteOn(0x90, 0x1E, 0x00);
    //    }
    Serial.print("ID: ");
    Serial.print(stepID);
    Serial.print(" Value: ");
    Serial.println(light);
  }
  // delay(1000);
  for (int i = 8; i > 1; i--) {
    digitalWrite(laserPin, LOW);
    small_stepper.setSpeed(motorSpeed);
    small_stepper.step(-stepSize);
    stepID = i;
    delay(motorDelay);
    digitalWrite(laserPin, HIGH);
    delay(laserDelay);
    light = analogRead(lightPin);
    //    if (light > threshold) {
    //      parsePosition();
    //    } else {
    //      noteOn(0x90, 0x1E, 0x00);
    //    }
    Serial.print("ID: ");
    Serial.print(stepID);
    Serial.print(" Value: ");
    Serial.println(light);
  }
  // delay(2000);

