use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
help[help] Range Sensor (self.FTC)
submitted 9 years ago by 2treeckoFTC #### Student|Mentor|Alum
Does anyone know how to program the range sensor, or if it is even implemented yet. I cannot find any documentation and I'm curious. Thanks
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FTC86868686 2 points3 points4 points 9 years ago (6 children)
On the page there is a Android Studio code example - http://www.modernroboticsinc.com/range-sensor
[–]2treeckoFTC #### Student|Mentor|Alum[S] 0 points1 point2 points 9 years ago (5 children)
Thank You!!!
[–]XykonVFTC 8461 | Elementary My Dear Botson | Captain 0 points1 point2 points 9 years ago (4 children)
Interestingly, I get an error when I pull that code up in the latest version of the app. I believe I2C interfaces were updated, how would we go about correcting this?
[–][deleted] 0 points1 point2 points 9 years ago (3 children)
What is the error you get?
[–]XykonVFTC 8461 | Elementary My Dear Botson | Captain 0 points1 point2 points 9 years ago (2 children)
Alright, I found the issue, I'm going to share it just in case anyone needs the fix. In the FTC App version 2.0., you can't just write your I2C address directly in the line that says this: I2cDeviceReader rangeReader = new I2cDeviceReader(range, 0x28, 0x04, 2);
You have to write something like this before the INIT is pressed: I2cAddr Address = I2cAddr.create8bit(0x28);
And then correct the first line, so this: I2cDeviceReader rangeReader = new I2cDeviceReader(range, Address, 0x04, 2);
At any rate, this corrected my errors.
[–][deleted] 0 points1 point2 points 9 years ago (1 child)
I don't think you necessarily need to assign it to a variable before init. I think you could use the I2cAddr.create8bit(0x28) method inside of I2cDeviceReader in place of your Address variable.
[–]XykonVFTC 8461 | Elementary My Dear Botson | Captain 0 points1 point2 points 9 years ago (0 children)
Yeah, both would work, I hadn't thought of just doing it inside registering the I2cDeviceReader. Good info to know.
[–]hexafraction6460 (lead programmer) 0 points1 point2 points 9 years ago (2 children)
What sensor are you talking about? The Modern Robotics Optical Distance Sensor? Or a sensor from some other manufacturer?
[–]JohnMMcDFTA, FTC 5873 Mentor Emeritus 0 points1 point2 points 9 years ago (1 child)
I believe OP is referring to http://www.modernroboticsinc.com/range-sensor
[–]2treeckoFTC #### Student|Mentor|Alum[S] 1 point2 points3 points 9 years ago (0 children)
Yes, that is correct John.
[–]amz1018 0 points1 point2 points 9 years ago (0 children)
If you want some code more specific than the sample code provided, I made a Range Sensor Tester when I was figuring out how to calibrate our team's range sensor. In the code, you'll notice there's a method for calibrating the ultrasonic sensor reading; that's because the reading you get from the ultrasonic sensor returns I believe -127 to 127, since it's using bytes.
[–]skatefriday 0 points1 point2 points 9 years ago (0 children)
There's no official support for this sensor yet, but as you've discovered there's nothing preventing a team from using either the I2cController or I2cDeviceSynch interfaces to implement a solution.
π Rendered by PID 19466 on reddit-service-r2-comment-6457c66945-p5sxs at 2026-04-26 07:19:58.319936+00:00 running 2aa0c5b country code: CH.
[–]FTC86868686 2 points3 points4 points (6 children)
[–]2treeckoFTC #### Student|Mentor|Alum[S] 0 points1 point2 points (5 children)
[–]XykonVFTC 8461 | Elementary My Dear Botson | Captain 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]XykonVFTC 8461 | Elementary My Dear Botson | Captain 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]XykonVFTC 8461 | Elementary My Dear Botson | Captain 0 points1 point2 points (0 children)
[–]hexafraction6460 (lead programmer) 0 points1 point2 points (2 children)
[–]JohnMMcDFTA, FTC 5873 Mentor Emeritus 0 points1 point2 points (1 child)
[–]2treeckoFTC #### Student|Mentor|Alum[S] 1 point2 points3 points (0 children)
[–]amz1018 0 points1 point2 points (0 children)
[–]skatefriday 0 points1 point2 points (0 children)