28044 Laser Range FInder
Interesting the only output I can find is using either "R" or "B" as a command. One sends out a string message with the distance buried in the output string, the other returns a binary number and I don't know how to change the number to a decimal so I can use it in code. I suppose real programmers and engineers would have no trouble but isn't a good portion of the intended market for hobbyist? How can I get a decimal number from this?
Comments
Jim
But I would be eternally grateful for a simple routine.
I'm not sure there's another option. How would you want the data output to be formatted?
I think the output called "binary" are the number values you want.
The LRF outputs data in a pretty standard way for industrial and hobbyist devices. It's always a bit of a trick converting data transmitted from a sensor into a useful value on the receiver side. I don't see any particular issues with the way the LRF sends data.
I do think it would have been nice if the example included a way of capturing the data in a variable. It doesn't do the user much good having the data in a character string.
I believe there are several ways of solving this. One is the "toInt" function. I think the demo code will require a bit of a rewrite to use "toInt" since (or so I think) the character data needs to be in a string. Here's a link to information about this function.
https://www.arduino.cc/en/Tutorial/StringToIntExample
Another option is to check the incoming data to see if the characters are numbers. If the character is a number then use it to build your variable. I haven't tested this, but I think something like this should work for the main loop section of the program.
Left Angle is 10
range = 0
@
Left Angle is 20
range = 0
@
Left Angle is 30
range = 0
@
Left Angle is 40
range = 0
@
Left Angle is 50
I would send you our complete code but I was afraid to choke up this thread.
I just dug out my Uno and LRF and I also received zeros.
I'll see if I can figure this out.
I just tested this version and it appears to work as expected.
Good to hear. You're welcome.