annotate sea/sea.ino @ 1:6f1cd84f8e23

Remove debugging from sea unit
author Daniel O'Connor <darius@dons.net.au>
date Sat, 11 Jul 2015 15:20:40 +0930
parents fe0a2f223e10
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
1 #include <Wire.h>
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
2 #include <Adafruit_MotorShield.h>
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
3 #include "utility/Adafruit_PWMServoDriver.h"
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
4
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
5 // Orange - Vertical M2+
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
6 // White/orange - Vertical M2-
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
7 // Green - Left M3+
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
8 // White/green - Left M3-
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
9 // Blue - Right M1+
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
10 // White/blue - Right M1-
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
11 // Brown - RS485 B
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
12 // Brown/white - RS485 A
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
13
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
14 // Motor shield object at default address
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
15 Adafruit_MotorShield AFMS = Adafruit_MotorShield();
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
16
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
17 // Motor objects
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
18 Adafruit_DCMotor *leftMotor = AFMS.getMotor(3);
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
19 Adafruit_DCMotor *rightMotor = AFMS.getMotor(1);
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
20 Adafruit_DCMotor *vertMotor = AFMS.getMotor(2);
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
21
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
22 void setup() {
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
23 Serial.begin(115200);
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
24
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
25 AFMS.begin(); // Start at default frequency
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
26 }
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
27
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
28 int
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
29 parseIn(char dir) {
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
30 int tmp;
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
31
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
32 while (Serial.read() != dir)
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
33 ;
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
34 while (Serial.read() != ':')
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
35 ;
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
36 tmp = Serial.parseInt();
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
37
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
38 return tmp;
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
39 }
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
40
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
41 void loop() {
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
42 int tmp;
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
43
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
44 tmp = parseIn('L');
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
45 if (tmp > 0)
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
46 leftMotor->run(FORWARD);
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
47 else
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
48 leftMotor->run(BACKWARD);
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
49 leftMotor->setSpeed(abs(tmp));
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
50
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
51 tmp = parseIn('R');
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
52 if (tmp > 0)
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
53 rightMotor->run(FORWARD);
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
54 else
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
55 rightMotor->run(BACKWARD);
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
56 rightMotor->setSpeed(abs(tmp));
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
57
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
58 tmp = parseIn('V');
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
59 if (tmp > 0)
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
60 vertMotor->run(FORWARD);
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
61 else
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
62 vertMotor->run(BACKWARD);
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
63 vertMotor->setSpeed(abs(tmp));
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
64 }
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
65
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
66 /*
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
67 * Local variables:
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
68 * mode: c++
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
69 * End:
fe0a2f223e10 Initial commit of split brain code for the Sea Dragon.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
70 */