Harsh Sharma Technicals

Everything About Technology At One Place

Codes And Circuit Diagrams

Code And Circuit Diagram For Ultrasonic Sensor Arduino

** if you want to buy the entire package with a re-programmable Arduino Click Here **

#include <Mouse.h>

const int trigpin= 8;

const int echopin= 7;

long duration;

int distance;

void setup()

{

pinMode(trigpin,OUTPUT);

pinMode(echopin,INPUT);

Serial.begin(9600);

}

void loop()

{

digitalWrite(trigpin,HIGH);

delayMicroseconds(10);

digitalWrite(trigpin,LOW);

duration=pulseIn(echopin,HIGH);

distance = duration*0.034/2;

Serial.println(distance);

}

 

IF YOU ARE GETTING A STRAY ERROR THEN COPY OR DOWNLOAD THE CODE FROM HERE

 



One thought on “Code And Circuit Diagram For Ultrasonic Sensor Arduino

  • Good! No doubt you are writing fine. I will pass Google Certifications on behalf of you for busy professionals and working students digital marketing certificates.Email me for details quyass_pak@hotmail.com

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *