int trig = 32;//the pine tree that emits the ultrasound int echo = 33;//the pine tree that receive the ultrasound long lecture_echo; long cm; void setup(){ pinMode(trig, OUTPUT); digitalWrite(trig, LOW); pinMode(echo, INPUT); Serial.begin(115200);//sensor baudrate } void loop(){ //sends ultrasound for 100 microseconds, then stops digitalWrite(trig, HIGH); delayMicroseconds(100); digitalWrite(trig, LOW); //read the value and convert it into cm lecture_echo = pulseIn(echo,HIGH); cm = lecture_echo /58; //displays the result Serial.print("Distance in cm :"); Serial.println(cm); delay(1000); }