IR Distance Sensor Help

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
reg bitley
 
Posts: 5
Joined: Tue Dec 22, 2009 2:36 pm

IR Distance Sensor Help

Post by reg bitley »

I recently purchased the Arduino Duemilanove board and the sensor pack from Adafruit. I have completed most of the example sketches and am ready to start improvising with the sensor pack. I want to make a distance sensor utilizing the Sony IR Distance Sensor and a push button and I am looking for a sketch with some basic code for the sensor. I would appreciate it if someone could provide a link. TIA

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: IR Distance Sensor Help

Post by adafruit »

you can use just analogread to read the value. the value will vary with distance.

User avatar
reg bitley
 
Posts: 5
Joined: Tue Dec 22, 2009 2:36 pm

Re: IR Distance Sensor Help

Post by reg bitley »

Thanks, that was easy enough. I marked off a 1x4 with 10cm increments and created 3/4"x4"x4" target with white paper taped on and made some initial test readings. I was surprised at the repeatability of the raw readings over the test length (10cm to 60cm), but they sure weren't linear. I've got to dust off the old math books now and come up with a 'non-linear' scaling formula. Thanks again.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: IR Distance Sensor Help

Post by adafruit »

good work! check the datasheet for some rough curves

User avatar
zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: IR Distance Sensor Help

Post by zener »

You can plot the values in Excel and do a regression on it. I would have assumed they would be linear, but I have never used that sensor.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”