Created
March 16, 2017 13:21
-
-
Save maxpromer/d8e65037e6416a1cbf406afad62a0025 to your computer and use it in GitHub Desktop.
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 characters
/* | |
* Codeing By IOXhop : www.ioxhop.com | |
*/ | |
#define SRF05_Trig_PIN 12 | |
#define SRF05_Echo_PIN 13 | |
void setup() { | |
pinMode(SRF05_Trig_PIN, OUTPUT); | |
pinMode(SRF05_Echo_PIN, INPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
digitalWrite(SRF05_Trig_PIN, LOW); | |
delayMicroseconds(5); | |
digitalWrite(SRF05_Trig_PIN, HIGH); | |
delayMicroseconds(10); | |
digitalWrite(SRF05_Trig_PIN, LOW); | |
unsigned int PulseWidth = pulseIn(SRF05_Echo_PIN, HIGH); | |
unsigned int distance = PulseWidth / 29 / 2; | |
Serial.print("Distance is "); | |
Serial.print(distance); | |
Serial.println(" cm."); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment