i programed this : int trigPin = 9;
int echoPin = 8;
float duration_us, distance_cm;
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
pulseIn(echoPin, HIGH);
Serial.print("distance: ");
Serial.print(distance_cm);
Serial.println(" cm");
delay(200);
}
And is working but the serial monitos tells me the distance is 0.00 cm
HELP
LarryD
3
Where are you setting distance_cm ?
The posting is not working.
(Read about code tags).
i dont have time for code tags im in school project in com lab
It took you longer to post this reply than it would have to add the code tags.
I hope you've got plenty of time, because without those and with this attitude you're going to be waiting a while.
system
Closed
8
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.