const int trig = 12; const int echo = 11; long sure; int uzaklik; void setup() { pinMode(trig, OUTPUT); pinMode(echo, INPUT); Serial.begin(9600); } void loop() { digitalWrite(trig, 0); delayMicroseconds(10); digitalWrite(trig, 1); delayMicroseconds(10); sure = pulseIn(echo, 1); uzaklik = (0.0343 * sure) / 2; Serial.print(uzaklik); Serial.println(" cm"); }
Categories:
Tags:
No responses yet