From: daniel watson Date: Wed, 12 Aug 2015 05:24:28 +0000 (-0700) Subject: move variables to tighter scope X-Git-Url: http://challenge-bot.com/repos/?p=challenge-bot;a=commitdiff_plain;h=4fb38d0258fc0574273cdcf1000cf2820e3297f6 move variables to tighter scope * also get rid of unused variables {forward,stop}_speed * make desired ping times local to loop, that's the only place they're used --- diff --git a/build-stages/g_follow/g_follow.ino b/build-stages/g_follow/g_follow.ino index 3c01a4d..344c46e 100644 --- a/build-stages/g_follow/g_follow.ino +++ b/build-stages/g_follow/g_follow.ino @@ -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);