Jump to content
43oh

saip

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. i tried this but it is not showing the exact cm, can any one help int trigPin = P1_6; int echoPin = P1_7; long duration; long distance; void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); } void loop() { digitalWrite(trigPin, LOW); // Added this line digitalWrite(trigPin, HIGH); delayMicroseconds(10); // Added this line digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration/58.2); Serial.println(distance); delay(1000); }
×
×
  • Create New...