Go to Post I thought of this at least a couple of years ago, but I didn't post because I didn't want to give Dave any fiendish ideas. He has enough without our help. - ChrisH [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-01-2015, 14:09
GHernandez2582 GHernandez2582 is offline
Registered User
FRC #2582
 
Join Date: Jan 2015
Location: Texas
Posts: 2
GHernandez2582 is an unknown quantity at this point
Help with Ultrasonic Sensor on Arduino Uno

I need help programming an Ultrasonic Sensor on an Arudino Uno. The Ultrasoinc is an LV-MAXSONAR-EZ. I've tried different methods and even downloaded this https://github.com/Diaoul/arduino-Maxbotix library , but I still can't get it to work. Does anyone have a method to make a this or a similar Ultrasonic Sensor work with the Arduino Uno and display the distance in inches and/or centimeters?
  #2   Spotlight this post!  
Unread 24-01-2015, 14:41
dave1027 dave1027 is offline
Registered User
FRC #1027
 
Join Date: Feb 2007
Location: West Springfield, MA
Posts: 14
dave1027 will become famous soon enough
Re: Help with Ultrasonic Sensor on Arduino Uno

i have done this a couple times, those sensor are great.
First ensure it is wired correctly:

when looking down at the sensor, with the pins at the bottom, supply ground on the right most pin and +5v to the next pin to the left.

connect the 3rd pin from the left to analog input 0.

Below is a basic version of a sketch that will work with this sensor.

long inches = 0;
long raw=0;
long rawavgsum=0;
long rawavg=0;
const int avgcounter = 90;

void setup() {
// initialize serial:
Serial.begin(9600);
// make the pins outputs:

}

void loop(){

for (int i = 0; i<avgcounter;i++)
{
raw = analogRead(0);
rawavgsum=raw+rawavgsum;
delay(10);
}

rawavg = rawavgsum/avgcounter;
inches = rawavg/2; //At 5 V on Vcc, the sensor is rated 9.8mV/ inch. pin range isis 0-1024 counts per 0-5V, 1 count = 4.8mV, 2 counts = 1 inch
Serial.print("avg Inches: ");
Serial.print(inches);
Serial.print("\n");
rawavgsum=0;
delay(250);
}
  #3   Spotlight this post!  
Unread 24-01-2015, 15:40
GHernandez2582 GHernandez2582 is offline
Registered User
FRC #2582
 
Join Date: Jan 2015
Location: Texas
Posts: 2
GHernandez2582 is an unknown quantity at this point
Re: Help with Ultrasonic Sensor on Arduino Uno

Thanks! Turns out my wiring was a bit off, but your's works too. I appreciate the help!
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:10.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi