Created
October 1, 2014 17:32
-
-
Save andijcr/a3051225d92320cb74f4 to your computer and use it in GitHub Desktop.
test hc-sr04
This file contains 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
//11 trig | |
//10 echo | |
//13 led | |
void setup(){ | |
pinMode(11, OUTPUT); | |
pinMode(10, INPUT); | |
pinMode(13, OUTPUT); | |
} | |
void loop(){ | |
digitalWrite(11, HIGH); | |
delay(10); | |
digitalWrite(11, LOW); | |
unsigned long distance=pulseIn(10, HIGH); | |
digitalWrite(13, HIGH); | |
delay(distance/1000); | |
digitalWrite(13, LOW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment