Zumo and Sharp IR sensor

Hi all!

I just got my Zumo Wednesday evening and assembled it yesterday and started in on learning how to use all the sensors and motors. I have it following a black line thanks to the examples I found with the various libraries I downloaded. Now to my question;

I also bought a Sharp small digital distance sensor (GP2Y0D815Z0F) and want to use it as a way of detecting objects close by. There is some confusion in what I have read on if this particular sensor can be used to measure distance or not. While right now I don’t need to, it would be good to get an affirmed answer on that.

Plan is to mount this sensor near or on the front above the blade and just code it so upon detection of something to change direction or something of the like. The question is, is there a way to poll this sensor every say 100ms but not have it cause the forward motion of the motors to studder. What I would like is for the function that polls the sensor and then sends the notice there is something in the way, to run independant of the loop function so within the loop I could use a Do While (sensor = 0); and this would run over and over smoothly until sensor becomes a “1” and calls the turn function.

Am I making this too hard? I just noticed in the LineFollower example the zumo does move ahead smooth because it is always polling for course corrections from the ReflectanceSensor.

Thanks for any help, this is really run to play with.

Jeff
KC9QQM

Hello, Jeff.

I am glad you are having fun with your Zumo. The GP2Y0D815Z0F Sharp Digital Distance Sensor can be used to detect if an object is present, but not how far away the object is. If you need to be able to detect the distance to an object, you might consider one of the Sharp analog distance sensors, such as the GP2Y0A60SZLF.

It should be possible to check the sensor many times per second and still have smooth movements. You might notice stutters if your program handles the sensor in a non-optimal way. If you try writing a sketch or modifying an example sketch to use the digital sensor, and have problems, you could post your code here, and I would be happy to take a look.

-Brandon

Thanks Brandon. Ordered some headers and such today so I can mount an other blank shield on top of the Zumo to have a place for the servo and sensor, once it is in I’ll dig back into it and let you know if I need help.

Jeff

Was playing with this a bit more yesterday. I did a quick sketch to set up the servo rotation and the sensor to monitor anything in it’s way but the way I had it, a function for each, didn’t work right as it did one then the other so it only “looked” at the sensor after the servo did a sweep.

How to I get the function for the sensor to be looked at all the time while the servo is panning it back and forth?

Do I need to actually put the sensor function in the sweep function?

Jeff

Combining your sensor function and servo function would probably work for what you are trying to do. You might run into problems if you are using blocking delays (e.g. the delay() function). If this becomes a problem, you might try looking at this “Blink WIthout Delay” example to see how you might use a non-blocking delay.

-Brandon