Introduction
Read moreThis project shows how to make the distance a meter using Ultrasonic and Arduino. We use Arduino IDE for coding.
The Ultrasonic sensor uses a NewPing library.
NewPinghttps://bitbucket.org/teckel12/arduino-new-ping/downloads/
- After downloading the NewPing library, extract it.
- You can see a NewPing folder.
- Copy the folder and paste it in C:\Program Files (x86)\Arduino\libraries.
#include <NewPing.h>
const int TriggerPin = 11;
const int EchoPin = 12
;
NewPing sonar(TriggerPin, EchoPin, 100);
void setup() {
Serial.begin(9600);
}
void loop() {
int cm = sonar.ping_cm();
Serial.println(cm);
delay(250);
}
After uploading this code and NewPing library:
- Restart your Arduino IDE
- Open Serial monitor 9600 baud


_iJWRidoCWR.jpg?auto=compress%2Cformat&w=900&h=675&fit=min)
_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)








Comments