Permalink
Browse files

Added laser control commands.

L = laser on
l = laser off
p = pan-
P = pan+
t = tilt-
T = tilt+
  • Loading branch information...
1 parent 0e13c15 commit dc55c4b1844479c69c3269c5b47dc9d2d9a6cdb8 @superatrain superatrain committed May 6, 2011
Showing with 56 additions and 1 deletion.
  1. +56 −1 SerialComms/SerialComms.pde
@@ -23,6 +23,7 @@ R - Reset
*/
#include <AFMotor.h>
+#include <Servo.h>
#define DEBUG 0
@@ -46,6 +47,14 @@ R - Reset
#define WheelForwardDirection FORWARD
#define WheelBackwardDirection BACKWARD
+#define LaserPowerPin 2
+#define PanPin 10
+#define TiltPin 9
+Servo laserPan;
+Servo laserTilt;
+int pan=90;
+int tilt=90;
+
/*
#define MotionStart 0
@@ -127,7 +136,9 @@ void setup() {
wheelMotor.setSpeed(WheelMotorSpeed);
wheelMotor.run(RELEASE);
-
+ laserPan.attach(PanPin);
+ laserTilt.attach(TiltPin);
+ pinMode(LaserPowerPin,OUTPUT);
}
void loop() {
@@ -202,6 +213,50 @@ void loop() {
//IR marker readout
IRMarkerMessage = !IRMarkerMessage;
break;
+ case 'L':
+ // Laser on:
+ digitalWrite(LaserPowerPin,1);
+ break;
+ case 'l':
+ // Laser off
+ digitalWrite(LaserPowerPin,0);
+ break;
+ case 'p':
+ // Pan-
+ pan-=5;
+ if (pan<0)
+ pan=0;
+ laserPan.write(pan);
+ Serial.print("Pan: ");
+ Serial.println(pan);
+ break;
+ case 'P':
+ // Pan+
+ pan+=5;
+ if (pan >165)
+ pan=165;
+ laserPan.write(pan);
+ Serial.print("Pan: ");
+ Serial.println(pan);
+ break;
+ case 't':
+ // Tilt-
+ tilt-=5;
+ if (tilt < 20)
+ tilt=20;
+ laserTilt.write(tilt);
+ Serial.print("Tilt: ");
+ Serial.println(tilt);
+ break;
+ case 'T':
+ // Tilt+
+ tilt+=5;
+ if (tilt>90)
+ tilt=90;
+ laserTilt.write(tilt);
+ Serial.print("Tilt: ");
+ Serial.println(tilt);
+ break;
case 'a':
Serial.println("Toggling auto move");
if(autoMove) {

0 comments on commit dc55c4b

Please sign in to comment.