Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
672 B
1
Indexable
Never
#define trigPin 13
#define echoPin 12
#define kLed 5



long sure;
long uzaklik;


void setup() {
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
pinMode(kLed,OUTPUT);

Serial.begin(9600);


}

void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

sure = pulseIn(echoPin, HIGH);
Serial.print("olculen sure");Serial.println(sure);

uzaklik= sure *0.034/2;
Serial.print("Uzaklik");
Serial.print(uzaklik);
Serial.println("CM olarak olculmustur.");

if(uzaklik<10)
{
  digitalWrite(kLed,LOW); 
}



else
{
   digitalWrite(kLed,HIGH); 
}
}