X-Git-Url: http://challenge-bot.com/repos/?p=challenge-bot;a=blobdiff_plain;f=build-stages%2Fb_right_sonar%2Fb_right_sonar.ino;fp=build-stages%2Fb_right_sonar%2Fb_right_sonar.ino;h=0000000000000000000000000000000000000000;hp=3d4af2ebac3596bfd01959628745c26eaa66f1a9;hb=35ffc3435298c78927cd70d765d6291f16325e5d;hpb=4f98acb2deaa2b3b89ee1cc212ca3109ba4ad973 diff --git a/build-stages/b_right_sonar/b_right_sonar.ino b/build-stages/b_right_sonar/b_right_sonar.ino deleted file mode 100644 index 3d4af2e..0000000 --- a/build-stages/b_right_sonar/b_right_sonar.ino +++ /dev/null @@ -1,52 +0,0 @@ -/* - 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 . - */ -int right_echo_pin = 6; -int right_trigger_pin = 7; - -int ping_microseconds = 0; -double sound_cm_per_microsecond_at_sea_level = 0.034029; -int count = 0; - -void setup(){ - Serial.begin(9600); - pinMode(right_echo_pin, INPUT); - pinMode(right_trigger_pin, OUTPUT);} - -void loop(){ - // make sure trigger pin is off, a.k.a. LOW - digitalWrite(right_trigger_pin, LOW); - delayMicroseconds(2); - - // send a 10 microsecond HIGH pulse to the trigger pin - digitalWrite(right_trigger_pin, HIGH); - delayMicroseconds(10); // leave the pin on for 10 microseconds - digitalWrite(right_trigger_pin, LOW); - - ping_microseconds = pulseIn(right_echo_pin, HIGH); - - // wait for the sonar sensor hardware to recover from pinging - delayMicroseconds(50); - - // print out the pulse time - Serial.print(ping_microseconds); - Serial.print(" = ping time (microseconds), "); - Serial.print(ping_microseconds * sound_cm_per_microsecond_at_sea_level / 2); - Serial.print(" = distance (cm). #"); - Serial.println(count++); - - // wait so it's easier to read the serial monitor. - // change delay to 0 for fullspeed. - // default is 333, which is about 1/3 of a second - delay(333);}