Skip to content

Instantly share code, notes, and snippets.

@debreuil
Created January 7, 2011 22:22
Show Gist options
  • Save debreuil/770215 to your computer and use it in GitHub Desktop.
Save debreuil/770215 to your computer and use it in GitHub Desktop.
void loop()
{
if (Serial.available())
{
char ch = Serial.read();
switch(ch) {
case '0'...'9':
serialReadNum = serialReadNum * 10 + ch - '0';
break;
case 's':
servo1.write(serialReadNum);
#ifdef DEBUG
Serial.print(serialReadNum);
#endif
serialReadNum = 0;
break;
case 'f':
stepperDirection = FORWARD;
moveMotorY();
serialReadNum = 0;
break;
case 'b':
stepperDirection = BACKWARD;
moveMotorY();
serialReadNum = 0;
break;
case 'l':
stepperDirection = BACKWARD;
moveMotorX();
serialReadNum = 0;
break;
case 'r':
stepperDirection = FORWARD;
moveMotorX();
serialReadNum = 0;
break;
case 'p':
initMotors();
currentDrillDepth = minDepth;
probeDown();
break;
case 'o':
serialReadNum = 0;
currentDrillDepth = minDepth;
servo1.write(minDepth);
delay(500);
servo1.detach();
#ifdef DEBUG
Serial.println("Turned Off");
#endif
break;
case 'd':
drillDown(serialReadNum);
serialReadNum = 0;
break;
case 'w':
delay(serialReadNum);
serialReadNum = 0;
break;
case 'a':
#ifdef DEBUG
Serial.println("attach motors ");
#endif
Serial.println("DrillTop");
//initMotors();
break;
case 'i':
int angle = servo1.read();
//volatile boolean probeSensor = digitalRead(sensorPin);
Serial.println("*** INFORMATION ***");
//Serial.print("probeSensor :");Serial.println(probeSensor==TOUCHING ? "touching" : "not touching");
Serial.print("probeSensor :");Serial.println(analogRead(analogPin));
Serial.print("servo angle :");Serial.println(angle);
Serial.print("currentDrillDepth :");Serial.println(currentDrillDepth);
break;
}
}
//AF_Stepper::refresh();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment