const int trigger_pin =12;
const int echo_pin = 11;
float sure;
float mesafe;
void setup()
{
pinMode(trigger_pin , OUTPUT);
pinMode(echo_pin , INPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(trigger_pin , HIGH);
delayMicroseconds(1000);
digitalWrite(trigger_pin , LOW);
sure = pulseIn(echo_pin , HIGH);
mesafe = (sure/2) / 28.5;
Serial.print(" cisme olan uzaklik = ");
Serial.print(mesafe);
Serial.println(" cm ");
Serial.println("---------------");
delay(500);
}
Hiç yorum yok:
Yorum Gönder