Created
March 17, 2017 17:40
-
-
Save maxpromer/6dad37822c049abfc61ba226f510bb6a 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 Trig_PIN 12 | |
| #define Echo_PIN 13 | |
| void setup() { | |
| pinMode(Trig_PIN, OUTPUT); | |
| pinMode(Echo_PIN, INPUT); | |
| Serial.begin(9600); | |
| } | |
| void loop() { | |
| digitalWrite(Trig_PIN, LOW); | |
| delayMicroseconds(5); | |
| digitalWrite(Trig_PIN, HIGH); | |
| delayMicroseconds(10); | |
| digitalWrite(Trig_PIN, LOW); | |
| unsigned int PulseWidth = pulseIn(Echo_PIN, HIGH); | |
| unsigned int distance = PulseWidth * 0.0173681; | |
| 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