Connecting sharp distance sensor to Zumo shield

How do I connect the distance sensor to Zumo shield ? -> this sensor

I am thinking of soldering the 3x1 male header into the front expansion area of the zumo shield (the upper pins), and connect with the output, Vcc, and ground. Is this correct?
Also when I am using the pins, I am only allowed to use A0, A2, and A3 ?


If you are not already using the pins in the front expansion, you should be able to add the sensor connections there. The sensor you linked to is a digital sensor, so you could use any digital I/O pin to connect to the sensor. You can find more information about the pinouts in the “Front expansion” section of the user’s guide.

- Grant

Would it be different if I connect it to a analog I/O?
Because whether we plug it into analog and digital pin, it won’t give accurate value, it can show 0 and 1 though…

The sensor you are using only reports whether there is an object in its detection range or not, so it only has a digital output and there is no benefit to connecting it to an analog input. It sounds like you want a sensor that reports the distance to the detected object. If that is the case, you might consider the GP2Y0A21YK0F or theGP2Y0A02YK0F Sharp analog distance sensors, which have a detection range of 10-80cm and 20-150cm, respectively.

- Grant

Are the analog pins available to connect two sensors Sharp Analog Distance Sensor GP2Y0A21YK0F 10-80cm


There should be analog pins available for two of those sensors, as long as you are not using them for other peripherals, like the reflectance sensor array. You can check which pins are available in the “Arduino pin assignment table” in the Zumo Shield for Arduino User’s Guide.

- Grant

Refelctancia sensor uses pins 4, A5, 11, A0, A2, 5, as is the default then you can help me by numbering the analog ports available for connecting the sensor sharp, and I do not understand much the description of the module expansion

Excuse me for my english


By default, the reflectance sensor array uses pins 4, 11, 5, A0, A2, and A3 (not A5). This picture in the user’s guide shows A5 being used by the reflectance array, but that is an optional modification to remap a specific sensor on that array after its trace has been cut.

As Grant mentioned in his last post, you can look at the pin assignment table in the Zumo user’s guide to see which analog pins are available to connect to your Sharp analog sensors. If you are using an unmodified reflectance sensor array, then analog pins A0, A2, A3 are already being used. So, that means A1, A4, and A5 should be available. Please note that those pins are also used for other optional functions that are described in that table, so you might have to choose between those and your Sharp sensors.

Also, if you tell me specifically what you do not understand about that description, I might be able to clarify it for you.


Exactly I want to use the analog pins to connect the sensors sharp, then they should go on pins A1, A4, A5, since I have not made any modification to Connect reflectance sensors, which should also modify the code that comes set to the high robot to include sharp sensor functions together with the rest of the program.

It looks like Jon’s response answered your questions, but it is a little difficult for me to fully understand your post. Did you have another question?

- Grant

My question is, where in the code that comes in the default sumo robot should add a sentence to help me control the sharp sensor? Because I connected the sensor on the A4 port and get nothing.

The source is:

int sensor = 4; 
int distancia; 


void loop()
  distancia =analogRead(sensor); 
  if (button.isPressed())  
    // si se presiona el botón, para y espera a que otra ves sea presionado
    motors.setSpeeds(0, 0);
if (distancia < 250)
int speed = getForwardSpeed();
    motors.setSpeeds(speed, speed);

It looks like your code only responds when it reads a value less than 250 on the analog pin. The output from the sensor might not be falling below that value. Could you try just reading the output and printing it using Serial.print()? If you are not sure how to do that, Arduino has an example on the webpage for analogRead().

By the way, when posting code, please use the code tags to display your code nicely in your post. I have edited your post to include them.

- Grant

First, let me congratulate your staff on the patience and civility present in your responses to queries on this forum. Secondly, I am a special education teacher at a middle school in California and I am starting a robotics club at our school. To this end we have purchased two zumos, two sumobots, and a sumovore w/arduino shield. So far, only the zumos are operational and we have been having a lot of fun with them. However, as we prepare to build the others and read the docs, we are jealous of the object detection capability and we want to add it to the zumos. We’ve read the front expansion section of the manual and we hope that we can simply add the sensors to unused pins and tweak the code provided for the sumovore w/arduino to make this happen. I guess we are asking for more specific directions on how to add object detection to the zumos. We are still learning to make sense of C for programming. Is this a good strategy, or can you point us in a better direction?
Thirdly, do you have any compelling recommendations for a 3d printer <$1000 that we can use to make robot parts ala adafruit’s rover
Finally, thanks for making robots fun and accessible.


Thank you for the kind words. You can add IR sensors like the one mentioned earlier in this thread and connect them through the front expansion area. This is a common modification and should work for object detection.

I am not very familiar with the Sumovore, but I suspect that code written for it will not work directly with our Zumo. However, depending on the sensors it uses, you might be able to port some of the code used for object detection. We do not have any example code for using sensors like that with the Zumo, but if you run into problems while implementing the sensors, you can post here for additional help.

I don’t have any recommendation for a specific 3D printer, but maybe one of the other forum members has a recommendation for one.

- Grant

I have connected My sharp ir sensor to the ground, 5v, and A4 pins but i’m a quite young and don’t quite understand the arduino code I have made it line follow etc but I cant get it to free roam and avoid obstacles or use the obstacle avoiding in sumo, line following code. Does anyone know where I could find the code or does anyone have code I could use or I could modify slightly to work.

Sorry if my grammar is hard to understand.

Thanks Heaps



In this thread, they discuss using the Zumo to do some object avoidance. The sensor is different, but poster MoonDocker links to some code that might be helpful.

- Grant