use motor to test wiring
[challenge-bot] / motor / motor.ino
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);}