start with left sonar and left motor
authordaniel watson <ozzloy@gmail.com>
Tue, 29 Jul 2014 07:21:27 +0000 (00:21 -0700)
committerdaniel watson <ozzloy@gmail.com>
Tue, 29 Jul 2014 08:31:27 +0000 (01:31 -0700)
* serial output will build from left to right

build-stages/b_left_sonar/b_left_sonar.ino [new file with mode: 0644]
build-stages/b_left_sonar/left-sonar.fzz [new file with mode: 0644]
build-stages/b_right_sonar/b_right_sonar.ino [deleted file]
build-stages/b_right_sonar/right-sonar.fzz [deleted file]
build-stages/c_both_sonars/c_both_sonars.ino
build-stages/d_left_motor/d_left_motor.ino [new file with mode: 0644]
build-stages/d_left_motor/left-motor.fzz [new file with mode: 0644]
build-stages/d_right_motor/d_right_motor.ino [deleted file]
build-stages/d_right_motor/right-motor.fzz [deleted file]

diff --git a/build-stages/b_left_sonar/b_left_sonar.ino b/build-stages/b_left_sonar/b_left_sonar.ino
new file mode 100644 (file)
index 0000000..4b648b2
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ 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/>.
+ */
+int left_echo_pin = 11;
+int left_trigger_pin = 12;
+
+int ping_microseconds = 0;
+double sound_cm_per_microsecond_at_sea_level = 0.034029;
+int count = 0;
+
+void setup(){
+  Serial.begin(9600);
+  pinMode(left_echo_pin, INPUT);
+  pinMode(left_trigger_pin, OUTPUT);}
+
+void loop(){
+  // make sure trigger pin is off, a.k.a. LOW
+  digitalWrite(left_trigger_pin, LOW);
+  delayMicroseconds(2);
+
+  // send a 10 microsecond HIGH pulse to the trigger pin
+  digitalWrite(left_trigger_pin, HIGH);
+  delayMicroseconds(10); // leave the pin on for 10 microseconds
+  digitalWrite(left_trigger_pin, LOW);
+
+  ping_microseconds = pulseIn(left_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);}
diff --git a/build-stages/b_left_sonar/left-sonar.fzz b/build-stages/b_left_sonar/left-sonar.fzz
new file mode 100644 (file)
index 0000000..b011301
Binary files /dev/null and b/build-stages/b_left_sonar/left-sonar.fzz differ
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 (file)
index 3d4af2e..0000000
+++ /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 <http://www.gnu.org/licenses/>.
- */
-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);}
diff --git a/build-stages/b_right_sonar/right-sonar.fzz b/build-stages/b_right_sonar/right-sonar.fzz
deleted file mode 100644 (file)
index 8fa1313..0000000
Binary files a/build-stages/b_right_sonar/right-sonar.fzz and /dev/null differ
index 2d850ffbbd164acdb1bf54a4f86addfbe77ad76b..931e1b16f0310c8e30ef9a311e91eed5749d0697 100644 (file)
@@ -18,9 +18,6 @@ int right_trigger_pin = 7;
 int left_echo_pin = 11;
 int left_trigger_pin = 12;
 
-int right_ping_microseconds = 0;
-int left_ping_microseconds = 0;
-double sound_cm_per_microsecond_at_sea_level = 0.034029;
 int count = 0;
 
 void on(int pin){
@@ -47,6 +44,12 @@ int ping(int trigger, int echo){
   delay(50);
   return ping_time;}
 
+double ping_to_cm(int ping_microseconds)
+{
+  double sound_cm_per_microsecond_at_sea_level = 0.034029;
+  return ping_microseconds * sound_cm_per_microsecond_at_sea_level / 2;
+}
+
 void setup(){
   Serial.begin(9600);
   pinMode(right_echo_pin, INPUT);
@@ -55,13 +58,19 @@ void setup(){
   pinMode(left_trigger_pin, OUTPUT);}
 
 void loop(){
-  right_ping_microseconds = ping(right_trigger_pin, right_echo_pin);
+  int left_ping_microseconds;
+  int right_ping_microseconds;
+  double left_distance;
+  double right_distance;
   left_ping_microseconds = ping(left_trigger_pin, left_echo_pin);
+  right_ping_microseconds = ping(right_trigger_pin, right_echo_pin);
+  left_distance = ping_to_cm(left_ping_microseconds);
+  right_distance = ping_to_cm(right_ping_microseconds);
   // print out the pulse time
-  Serial.print(right_ping_microseconds);
-  Serial.print(" = right ping microseconds, ");
-  Serial.print(left_ping_microseconds);
-  Serial.print(" = left ping microseconds. #");
+  Serial.print(left_distance);
+  Serial.print(" = left distance (cm), ");
+  Serial.print(right_distance);
+  Serial.print(" = right distance (cm). line #");
   Serial.println(count++);
 
   // wait so it's easier to read the serial monitor.
diff --git a/build-stages/d_left_motor/d_left_motor.ino b/build-stages/d_left_motor/d_left_motor.ino
new file mode 100644 (file)
index 0000000..e2d7a56
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ 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_pin = 8;
+int left_motor_forward_pin = 9;
+int left_motor_backward_pin = 10;
+
+void setup(){
+  // the arduino will change the voltage on these pins
+  //  therefore, these pins are OUTPUT pins
+  pinMode(left_motor_speed_pin, OUTPUT);
+  pinMode(left_motor_forward_pin, OUTPUT);
+  pinMode(left_motor_backward_pin, OUTPUT);}
+
+void loop(){
+  digitalWrite(left_motor_backward_pin, LOW);
+  digitalWrite(left_motor_forward_pin, HIGH);
+  analogWrite(left_motor_speed_pin, 255);}
diff --git a/build-stages/d_left_motor/left-motor.fzz b/build-stages/d_left_motor/left-motor.fzz
new file mode 100644 (file)
index 0000000..57a8f00
Binary files /dev/null and b/build-stages/d_left_motor/left-motor.fzz differ
diff --git a/build-stages/d_right_motor/d_right_motor.ino b/build-stages/d_right_motor/d_right_motor.ino
deleted file mode 100644 (file)
index a27b984..0000000
+++ /dev/null
@@ -1,31 +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 <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;
-
-void setup(){
-  // the arduino will change the voltage on these pins
-  //  therefore, these pins are OUTPUT pins
-  pinMode(right_motor_speed_pin, OUTPUT);
-  pinMode(right_motor_forward_pin, OUTPUT);
-  pinMode(right_motor_backward_pin, OUTPUT);}
-
-void loop(){
-  digitalWrite(right_motor_backward_pin, LOW);
-  digitalWrite(right_motor_forward_pin, HIGH);
-  analogWrite(right_motor_speed_pin, 255);}
diff --git a/build-stages/d_right_motor/right-motor.fzz b/build-stages/d_right_motor/right-motor.fzz
deleted file mode 100644 (file)
index b70b07e..0000000
Binary files a/build-stages/d_right_motor/right-motor.fzz and /dev/null differ