IOT Virtual Lab
Home
Simulation Window
Go Back
Interfacing of Arduino with Ultrasonic Sensor :
Show Radar
ARDUINO CODE
#define echoPin 11 #define trigPin 12 long duration, distance; void setup(){ Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); } void loop(){ digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance= 0.034/2; Serial.println(distance); delay(50); } #INSTRUCTIONS Click inside the radar to render an object within the detection range of Ultrasonic sensor.
Start Simulation