Last active
April 6, 2018 10:31
-
-
Save nix010/c6b2d425f9962ee79c54956a5d71fc5f to your computer and use it in GitHub Desktop.
Revisions
-
nix010 revised this gist
Apr 6, 2018 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,8 +5,11 @@ #define MAX_DISTANCE 100 // Maximum distance we want to ping for (in centimeters). Maximum sensor #define US_ROUNDTRIP_CM 58 void setup() { NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. pinMode(ECHO_PIN, OUTPUT);// Open serial monitor at 115200 baud to see ping results. } void loop() { unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS). @@ -18,6 +21,6 @@ void loop() { Serial.println("cm"); if(distance < 30 && distance > 0 ){ // distance from 0-30 cm } } -
nix010 revised this gist
Apr 4, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // https://docs.google.com/presentation/d/1rrYLHVR3_Fc7mmvc8I8zGOhtoBDN02RjF_-aecimZdg/edit?usp=sharing #include <NewPing.h> #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor. #define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor. -
nix010 revised this gist
Apr 4, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor. #define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor. #define MAX_DISTANCE 100 // Maximum distance we want to ping for (in centimeters). Maximum sensor #define US_ROUNDTRIP_CM 58 NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. pinMode(11, OUTPUT);// Open serial monitor at 115200 baud to see ping results. -
nix010 created this gist
Apr 4, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ #include <NewPing.h> #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor. #define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor. #define MAX_DISTANCE 100 // Maximum distance we want to ping for (in centimeters). Maximum sensor #define US_ROUNDTRIP_CM 100 NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. pinMode(11, OUTPUT);// Open serial monitor at 115200 baud to see ping results. void loop() { unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS). unsigned int distance = uS / US_ROUNDTRIP_CM; Serial.print("Ping: "); Serial.print(distance); // Convert ping time to distance in cm and print result (0 = outside set distance range) Serial.println("cm"); if(distance < 30 && distance > 0 ){ // } }