Skip to content

Instantly share code, notes, and snippets.

@nesendal
Created September 18, 2018 09:56
Show Gist options
  • Save nesendal/87b65618b3346b9c0367acce4aadace4 to your computer and use it in GitHub Desktop.
Save nesendal/87b65618b3346b9c0367acce4aadace4 to your computer and use it in GitHub Desktop.
/*
*/
void setup() {
//put your setup code here, to run once:
pinMode(9,OUTPUT);
pinMode(8,INPUT);
pinMode(4,OUTPUT);
}
void loop() {
//put your main code here, to run repeatedly:
long sure,mesafe;
digitalWrite(9,LOW);
delayMicroseconds(2);
digitalWrite(9,HIGH);
delayMicroseconds(10);
digitalWrite(9,LOW);
sure=pulseIn(8,HIGH);
mesafe=(sure/2)29.1;
if(mesafe<5)
{
digitalWrite(4,HIGH);
}
else
{
digitalWrite(4,LOW);
}
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment