CODE of Ultrasonic sensor with Arduino Uno Copy



After making the connection, click on the code bar.

Drag and Drop the “If Else” block in the “coding area”. Then read the ultrasonic sensor trigger and echo pin and compare it with the distance 20cm 

If the distance will be lesser than 20cm then the Led will glow else the Led will not Glow.