Skip to content
Browse files

Added claw control.

  • Loading branch information...
1 parent 1dfb093 commit e4ae739dbffee8ee60f2071646cc3ea06422f9a5 @superatrain superatrain committed Dec 7, 2011
Showing with 26 additions and 4 deletions.
  1. +26 −4 SerialComms/SerialComms.pde
View
30 SerialComms/SerialComms.pde
@@ -1,4 +1,4 @@
-/* This sketch details serial communications over USB or XBee:
+sd /* This sketch details serial communications over USB or XBee:
q - Query Status
Q - Query Verbose Status
@@ -21,13 +21,17 @@ l - turn laser off
t### - tilt 20-90
p### - pan 0-165
+c### - claw grip 0-180
+
e# - play Darth Vader evil sound 1, 2 or 3
i - Toggle IR marker message ("--MARKER--")
a - Toggle move until IR hit then reverse
d - Automatic laser DEMO
R - Reset
+
+Notice: Claw is on Motor 2's pin. Do not use motor 2!
*/
#include <AFMotor.h>
@@ -51,6 +55,7 @@ R - Reset
#define WinchLoweringDirection FORWARD
#define WinchRaisingDirection BACKWARD
+#define ClawPin 3
#define WheelForwardDirection FORWARD
#define WheelBackwardDirection BACKWARD
@@ -65,9 +70,10 @@ R - Reset
Servo laserPan;
Servo laserTilt;
+Servo claw;
int pan=90;
int tilt=90;
-
+int grip=180;
/*
#define MotionStart 0
@@ -77,8 +83,8 @@ int tilt=90;
*/
//Globals
-AF_DCMotor wheelMotor(3, MOTOR12_8KHZ);
-AF_DCMotor winchMotor(4, MOTOR12_8KHZ);
+AF_DCMotor wheelMotor(3, MOTOR12_8KHZ); // Pin 5
+AF_DCMotor winchMotor(4, MOTOR12_8KHZ); // Pin 6
//State Globals
boolean winchDown = false;
@@ -182,6 +188,8 @@ void setup() {
laserPan.attach(PanPin);
laserTilt.attach(TiltPin);
+ claw.attach(ClawPin);
+
pinMode(LaserPowerPin,OUTPUT);
delay(10);
Serial.println("Finished Booting.");
@@ -321,6 +329,20 @@ void loop() {
Serial.println(tilt);
}
break;
+ case 'c': // Claw
+ delay(4); // give it a few ms to get the value - Experimentally determined.
+ if ( Serial.available() >2 )
+ {
+ char c[3];
+ c[0] = Serial.read();
+ c[1] = Serial.read();
+ c[2] = Serial.read();
+ int claw_grip = atoi(c);
+ claw.write(claw_grip);
+ Serial.print("CLAWED! ");
+ Serial.println(claw_grip);
+ }
+ break;
case 'e':
// make Evil sound
delay(4); // give it a few ms to get the value. 1 / 9600baud * 8bits/byte + 1 * 1000ms/s = 0.94ms / byte + overhead, or 4ms minimum to work....

0 comments on commit e4ae739

Please sign in to comment.
Something went wrong with that request. Please try again.