move variables to tighter scope
authordaniel watson <ozzloy@gmail.com>
Wed, 12 Aug 2015 05:24:28 +0000 (22:24 -0700)
committerdaniel watson <ozzloy@gmail.com>
Wed, 12 Aug 2015 05:24:28 +0000 (22:24 -0700)
* also get rid of unused variables {forward,stop}_speed
* make desired ping times local to loop, that's the only place they're used

build-stages/g_follow/g_follow.ino

index 3c01a4d7cf0c2c3282d927d9f853978b220a8d87..344c46e76a67898134e4af8600c11d8930763d57 100644 (file)
@@ -28,10 +28,6 @@ int left_motor_speed_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;
-
 void on(int pin){
   digitalWrite(pin, HIGH);}
 
@@ -124,8 +120,9 @@ 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);