use motor to test wiring
authordaniel watson <ozzloy@gmail.com>
Sun, 3 Nov 2013 17:04:53 +0000 (09:04 -0800)
committerdaniel watson <ozzloy@gmail.com>
Sun, 3 Nov 2013 17:04:53 +0000 (09:04 -0800)
motor/README [new file with mode: 0644]
motor/motor.ino [new file with mode: 0644]

diff --git a/motor/README b/motor/README
new file mode 100644 (file)
index 0000000..bf8f063
--- /dev/null
@@ -0,0 +1,11 @@
+(how to use this
+ (connect your robot to your computer via usb cable)
+ (open arduino ide)
+ (in arduino ide, open motor.ino)
+ (hit the upload button)
+ (your robot's wheels should start moving forward slowly)
+ (yaay!)
+ (you can reverse the direction a motor spins by plugging it into
+  the motor controller differently.  take the wires that come out of
+  the motor and swap where they plug into the motor controller)
+ (yaay!))
\ No newline at end of file
diff --git a/motor/motor.ino b/motor/motor.ino
new file mode 100644 (file)
index 0000000..62d8bee
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as
+    published by the Free Software Foundation, either version 3 of the
+    License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// define which pins are connected to which components
+int left_motor_speed = 3;
+int left_motor_forward = 4;
+int left_motor_backward = 5;
+
+int right_motor_speed = 10;
+int right_motor_forward = 9;
+int right_motor_backward = 8;
+
+void setup(){
+  pinMode(left_motor_speed, OUTPUT);
+  pinMode(left_motor_forward, OUTPUT);
+  pinMode(left_motor_backward, OUTPUT);
+
+  pinMode(right_motor_speed, OUTPUT);
+  pinMode(right_motor_forward, OUTPUT);
+  pinMode(right_motor_backward, OUTPUT);
+
+  digitalWrite(left_motor_speed, LOW);
+  digitalWrite(left_motor_forward, LOW);
+  digitalWrite(left_motor_backward, LOW);
+
+  digitalWrite(right_motor_speed, LOW);
+  digitalWrite(right_motor_forward, LOW);
+  digitalWrite(right_motor_backward, LOW);}
+
+void loop(){
+  digitalWrite(left_motor_forward, HIGH);
+  digitalWrite(left_motor_backward, LOW);
+  analogWrite(left_motor_speed, 128);
+
+  digitalWrite(right_motor_forward, HIGH);
+  digitalWrite(right_motor_backward, LOW);
+  analogWrite(right_motor_speed, 128);}