Project showcase
Ultrasonic Rangefinder with Processing

Ultrasonic Rangefinder with Processing © GPL3+

Obstacle distance is measured using ultrasonic sensor and Arduino. The data is processed using Processing and the distance is marked.

  • 15,295 views
  • 4 comments
  • 22 respects

Components and supplies

Apps and online services

About this project

This project is used to measure the distance of the obstacles.Ultrasonic range module is used to measure the distance.The video contains complete tutorial.






Code

Arduino codeArduino
upload the code into the arduino
#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);
}
processing codeProcessing
run this code on processing to plot the disatance
import processing.serial.*;  
Serial myPort;  
String data="" ;
PFont  myFont;  
void setup()
{
size(1366,900); // size of processing window
background(0);// setting background color to black
myPort = new Serial(this, "COM3", 9600);
myPort.bufferUntil('\n');
}
void draw()
{
  background(0);
  textAlign(CENTER);
  fill(255);
  text(data,820,400);
  textSize(100);
  fill(#4B5DCE);
  text("              Distance :        cm",450,400);
   noFill();
   stroke(#4B5DCE);
}
void serialEvent(Serial myPort)
{
 
  data=myPort.readStringUntil('\n');
}

Schematics

Circuit diagram
connect the sensor to the arduino board as shown in the picture
Untitled 2 gnxskuh4ib

Comments

TEAM DIY

Vaisakh1997
Vaisakh1997
  • 7 projects
  • 9 followers
Default
shafeeque
  • 6 projects
  • 1 follower
Default
Boniface
  • 5 projects
  • 1 follower

Additional contributors

  • Developed by Vaisakh

Published on

October 17, 2017

Members who respect this project

AdambenzDefaultDefaultPhotoDefaultDefaultProfilepic

and 15 others

See similar projects
you might like

Similar projects you might like

Ultrasonic Ranging Using Arduino and Processing (Radar)

Project showcase by Bharath Rao M

  • 42,557 views
  • 18 comments
  • 69 respects

Scaling an Image in Processing with Ultrasonic Sensor

Project tutorial by Najad

  • 3,695 views
  • 0 comments
  • 17 respects

Door Alarm With Ultrasonic Sensor

Project showcase by MattG

  • 15,783 views
  • 5 comments
  • 18 respects

Basic Ultrasonic Tutorial

by Damien Murtagh

  • 8,368 views
  • 5 comments
  • 35 respects
Add projectSign up / Login