From 4d60ae623edd000b8413ee7afbb8e1ef23d7ae98 Mon Sep 17 00:00:00 2001 From: daniel watson Date: Sun, 3 Nov 2013 09:04:53 -0800 Subject: [PATCH] use motor to test wiring --- motor/README | 11 +++++++++++ motor/motor.ino | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 motor/README create mode 100644 motor/motor.ino diff --git a/motor/README b/motor/README new file mode 100644 index 0000000..bf8f063 --- /dev/null +++ b/motor/README @@ -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 index 0000000..62d8bee --- /dev/null +++ b/motor/motor.ino @@ -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 . + */ + +// 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);} -- 2.30.2