define wiring in separate file
[challenge-bot] / build-stages / g_follow / g_follow.ino
index 54c7967200fb0fde1a09ffe133f09bdbe5fb8b79..b9cc4af943a01f5a3c06505fc3cab86198551c30 100644 (file)
@@ -1,36 +1,7 @@
-/*
- 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.
+// license info at bottom of file
+// tl;dr AGPLv3+
 
-    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 right_motor_speed_pin = 3;
-int right_motor_forward_pin = 4;
-int right_motor_backward_pin = 5;
-
-int right_echo_pin = 6;
-int right_trigger_pin = 7;
-
-int left_motor_speed_pin = 8;
-int left_motor_forward_pin = 9;
-int left_motor_backward_pin = 10;
-
-int left_echo_pin = 11;
-int left_trigger_pin = 12;
-
-// you'll need to adjust these based on your sonar sensor's behavior
-int desired_right_ping_time = 800;
-int desired_left_ping_time = 800;
+#include "bot_map.h"
 
 void on(int pin){
   digitalWrite(pin, HIGH);}
@@ -85,14 +56,6 @@ int ping(int trigger, int echo){
   delay(50);
   return ping_time;}
 
-void backup(int backup_time){
-  go(-250, -250);
-  delay(backup_time);}
-
-void turn_around(int turn_around_time){
-  go(-250, 250);
-  delay(turn_around_time);}
-
 void setup(){
   Serial.begin(9600);
 
@@ -118,28 +81,56 @@ void setup(){
   off(right_motor_speed_pin);
   off(right_motor_forward_pin);
   off(right_motor_backward_pin);
-  off(right_trigger_pin);}
+  off(right_trigger_pin); }
 
-void loop(){
+void loop() {
   int left_speed;
   int right_speed;
 
-  int forward_speed = 250;
-  int stop_speed = 0;
+  // you'll need to adjust these based on your sonar sensor's behavior
+  int desired_right_ping_time = 800;
+  int desired_left_ping_time = 800;
 
   unsigned int actual_left_ping_time = ping(left_trigger_pin, left_echo_pin);
   unsigned int actual_right_ping_time = ping(right_trigger_pin, right_echo_pin);
 
+  /* int left_led_value = (int)(actual_left_ping_time / 16.0); */
+  /* int right_led_value = (int)(actual_right_ping_time / 16.0); */
+
+  /* analogWrite(left_led_pin, left_led_value); */
+  /* analogWrite(right_led_pin, right_led_value); */
+
+  /* Serial.print("left led value = "); */
+  /* Serial.print(left_led_value); */
+  /* Serial.print(", right led value = "); */
+  /* Serial.print(right_led_value); */
+
   left_speed = actual_left_ping_time - desired_left_ping_time;
   right_speed = actual_right_ping_time - desired_right_ping_time;
 
-  Serial.print("left: ping = ");
+  Serial.print("left: ping = ");
   Serial.print(actual_left_ping_time);
   Serial.print(" speed = ");
   Serial.print(left_speed);
   Serial.print(" right: ping = ");
   Serial.print(actual_right_ping_time);
   Serial.print(" speed = ");
-  Serial.println(right_speed);
+  Serial.print(right_speed);
+  Serial.println();
+
+  go(left_speed, right_speed); }
 
-  go(left_speed, right_speed);}
+/*
+ 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/>.
+ */