Let's Make Robots!

Start Here Problems... Mainly the IR Sensor



Ok, I completely made my robot, everything working properly, except for my SHARP IR Sensor which i fried, so i ordered a replacement one, I hooked it up following the instructions,put in the batteries and put in the code, and now its working just like my fried sharp did, its looking both directions, and moving backwards (even though im positive it should be set to go forward i even just enter the forward code and it went forwards) no matter whats in front of it (or not in front of it) it does the same thing, also it felt like it was overheating (by the way when i typed in the ADC code it seemed like it was working) so i checked my connections and i found something was plugged in wrong, i plugged it right, (I accidentally plugged the IR sensor in wrong) and tryed testing it, nothing happened so i checked the batteries and there must have been a spark or something because it shocked me (making me move my robot a little and the batteries fell out) so i unplugged everything and plugged everything in and checked every connection and made sure nothing was overheating and put the batteries back in, this time smoke started pouring out from the batteries (or thats at least where  it looked like it was coming from) So i took the batteries out, unplugged the SHARP, checked connections, etc. nothing was overheating so i put in the batteries and nothing, the servo didn't even turn, so i used some other rechargeable batteries that i knew had full charge and put them in, still nothing, any ideas to what could be wrong (or fried)??? New Problem

When i plug my robot into my computer and do the readadc command on pin 1, 2, or 3 i get the number 255 when i try it on pin 0 i get a combinations of these numbers: 4, 5, 6, 10, 11, 12, 15, 17, 18, 19 and the combinations switches every 5 seconds no matter if the object it was looking at was stationary for those 5 seconds or if it was moving, but i can see a dim red light in the IR Sensor so i know its working... i've plugged the IR Sensor into every combination of  the 3 pins and have done the readadc pin 1, 2, and 3 on every combination of Sharp connections, (the main connection I've been testing on red blue black or V, Vout, gnd) Any ideas as what could be the problem?


Robot.jpg389.48 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.



readadc pinnumber,b1


goto main

Now get a ruler and a book. Use the book as a target and position it at various distances from the sensor. Use the ruler to measure these distances. Write down the readings you are getting and the distances they go with. Be sure the debug numbers are increasing and decreasing based on the distance of the target and that they are within reasonable ranges.

Now, based on your new data table of distance numbers, pick a "dangerlevel" distance. Plug this into your main code. See what happens. If there is still a problem, you now know that it is not the sensor or it's data, it is elsewhere in your code. It could be as simple as a < or a > in your if sharpsensor < or > dangerlevel...

It could be a lot of things. Eliminate what it could be, step-by-step and you will end up with what it is.

when i tell my computer to readadc pin 1 i just get the number 255 when i test it on pin 0 I get number combinations out of these numbers 4,5,6,10,11,12,15, 17,18,19 and it doesn't seem to change that pattern if i move the book, if the book is in the same place for more than 5 seconds the pattern will change to a different combination of those numbers and if i move the book it just continues whatever pattern it was on, not increasing or decreasing. any idea as to what could be wrong? i can still see the red light (pretty dim though) and i've tried doing readadc pin 1, 2, and 3 and i've plugged the Sharp Wires into every combination and tried readadc pin 1,2, and 3 on every combination. Does this mean theres a problem with the Sharp IR or what? 

Just to make sure: Is your Sharp connected like this (image from AXE020.pdf):

If it's connected like that then you have connected it correctly. Hopefully you haven't fried your Sharp yet by trying "every combination of Sharp connections". I really don't know what would happen if you reverse polarity (mix up red and black wire) or connect Vo (blue wire in your case) to V1+ or 0V. In worst case the Sharp's gonna be fried so don't just plug things in without knowing what you are doing.

Back to your problem:

I assume that your connections are now like they are in this picture (shorting block moved to its correct place of course) and my picture above. If they are then the reason why you are getting 255 from ADC pins 1, 2 and 3 is quite obvious. Just look at picture above and think how you have connected ADC pins 1, 2 and 3. Right, you have connected then to V1+. What does that mean? It means Analogue to Digital Converter (ADC) sees V1+ in all those pins. Because Picaxe's ADC measures voltage between 0V and V1+ it means that ADC sees the maximum voltage and that means readadc will give the maximum value (255).

I didn't notice you telling what Sharp sensor you have. I'm guessing it's either GP2D12 or GP2D120. GP2D12 has measuring distance ranging from 10cm to 80cm and GP2D120 has measuring distance ranging from 4cm to 30cm. When you were testing your sensor did you have you obstacle (book) within the range? Also, did you know that the value you get from readadc will get BIGGER when the obstacle is CLOSER when using these sensors? You can figure that out if you understand how ADC works and read the Sharp sensors datasheet (for example here for GP2D12 and here for GP2D120).

Now, if you are sure your connections are correct try your sensor once again with the code Chris posted earlier. Place the obstacle (book or whatever) 10cm away from the sensor. What values are you getting from the sensor? If you move the obstacle placing it 15cm away from the sensor what values are you getting now? Try other distances too and make sure the distance is within acceptable range. Just don't touch or move anything when you are reading the values.


I have a GP2D12  I have it connected just like the picture above, I can still see a faint red light in the Sharps Eye, but as for the distance results all of them are combination of 1 through 12 Here are the results anyway: 10 cm = 1,2,4,5,6,7,8,9,10,11,12           15 cm = 2,3,5,6,7,9,10,11,12           30 cm = 1,3,5,6,7,8,10,12        and when i moved it back to 10 cm from 30 cm the results changed (but the numbers where still in the 1-12 range) Do you think i fried it even though the red lights still on? thanks for all the help!

Also, I've had enough of you, and the Start Here Robot and the guy who wrote the code is Nuts.

Just Kidding Sometimes. If you send me your home address to zeitron@yahoo.com I will mail you a working sensor to test. I have one GP2D12 that won't go to use because I failed on the Start Here robot. It was just too advanced for me and the guy who wrote the code is Nuts. Did I mention that the guy who wrote the code is Nuts? Anyway, if you get it working then your one step closer to a dangerously clean navigation code using the SRF05 written by the same guy who is Nuts............

If you can tell I'm angry it's because I wanted to Start Here just as much as you but I didn't have the brains Man!


Nah Its ok i can order another one, I live in Alaska, US and shipping cost a lot to ship anything from anywhere else internationally or nationwide, I think i might have found the problem too, I think there might be a problem with the project board...

What's Up! You've been at this for a while. If your sensors measurements are not correct then something may be wrong but I don't think you fried the sensors so don't toss them so quickly. You can contact Acroname and they'll provide some support regarding all the Sharp models. They have been promoting the Sharp sensors for a while now and think they even had a troubleshooting guide once so give them a ring and see what they say regarding your situation. Location: USA

I know one thing you're not suppose to do and that is turn or loosen that screw located on the back of the sensor which would affect the calibration if I remember correctly. 


If I had to guess I'd say your Sharp's fried. You can test your Sharp with a multimeter if you want. Just power the Sharp directly from batteries and measure the voltage between Sharp's Vo and GND. When you move an object in front of the sensor the voltage should follow the curve given in the datasheet (page 4). Just be careful not to short circuit anything if you go ahead and test your sensor this way.

Another possibility could be that Picaxe's ADC is faulty/fried but I don't really think that's the case here. You can test that too if you have an extra potentiometer lying around. Connect potentiometer's center pin to Picaxe's analogue input, potentiometer's left pin to V1+ and potentiometer's right pin to 0V. Using the test code poster earlier you should get values between 0 and 255 when you turn the potentiometer.

That's all I can think of right now. I'm out of ideas.


I actually think that its the Picaxe's ADC Pin is faulty because i just noticed this today, I was just checking the IR Sensors connections again and found that the middle pin (input pin) was able to be moved and it was bent in an awkward direction and so i bent it back to straight, the soldering connection looks good, but i don't know, and i don't have a potentiometer to check it (im going to buy one today or tomorrow) if this were the case would i need to replace my whole project board? as for the Sharp Sensor, (tested with 1.5 volts) if i move my hand in front of it the voltage will start to vary, but if i keep my hand still it will go to 1.5 volts and nothing else, to me this seems like something is wrong with it because if it stays at the voltage it was given when it looks at still objects how would it be able to detect them in this code?

If the pin on the board is damaged you can replace it. Use multimeter to check if they are ok. Locate the pinout of your Picaxe chip from Picaxe manuals and check the resistance between project board analogue input pin and corresponding ADC pin of the chip. Resistance should be 0 ohms.

If you don't have potentiometer lying around you can build a voltage divider (potentiometer is a kind of "variable" voltage divider) if you have some resistors. I take that you are new to electronics so playing with a potentiometer/voltage divider and familiarizing yourself with Ohm's law could be a nice exercise. Simplest thing would be measuring resistance between all potentiometers pins (without hooking it up to anything) with a few different potentiometer's positions so you get to know how it works. Keep your amps down when you connect things to your Picaxe so you won't burn anything. With a simple voltage divider to test a ADC it would not really matter but high currents would just waste power. Too high currents will also make your robots smoke as you noticed earlier. Remember that you are dealing with milliamps here (for example Picaxe's digital outputs can source/sink 20 milliamps per pin). You can find current ratings from your component's manuals and datasheets.

You tested your Sharp with 1.5 volts. That's not enough. Read the datasheet again carefully. From the datasheet you can find Operating Supply Voltage. That's the voltage you must use with your sensor.