Skip to content

Instantly share code, notes, and snippets.

@andijcr
Created October 1, 2014 17:32
Show Gist options
  • Save andijcr/a3051225d92320cb74f4 to your computer and use it in GitHub Desktop.
Save andijcr/a3051225d92320cb74f4 to your computer and use it in GitHub Desktop.
test hc-sr04
//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