IR sensor

hey guys, programming problem wth me, i just gor the Sharp GP2D12 IR Sensor and i want to detect thing like that, but when i run Jim’s code from the tutorial for the 4wd rover for autonomous operation, it doesn;t seem to work, all the numbers in ternimal 1 are like 510,511, 508, sticking just around there, and even when i wave my hand in from of it it doesn’t work, only is i move my hand very fast in front of it does it get any type of result, usually dropping down into the 400 range

heres the tutorial btw, i dl and ran this program that i changed to work for only 1 sensor, gp2d12bb.bas

lynxmotion.com/images/html/build066.htm

maybe i messed up with the code or something? idk, someone please lend a hand :confused:

IDK. It should work. All I can say is, did you hook up the sensors right? Battery on? 5V jumper on the pins there setup on? Program it right? hmmmm, thats got me stumped!

well, if i hooked the sensor up wrong it wouldn’t be giving me any feedback at all, and yea, i have the jumper on 5 volts, and thats what im asking about, the program

oh so it does give some feedback but I suppose it is limited…hmmmm, well Ive never had that problem. Sorry dude, cant help you there… :frowning:

99.21 - 10 cm 99.21 - 10 cm 97.85 - 10 cm 97.85 - 10 cm 97.07 - 10 cm 96.87 - 10 cm 96.48 - 10 cm 96.67 - 10 cm 97.26 - 10 cm 97.46 - 10 cm 97.65 - 10 cm 99.80 - 10 cm 99.60 - 10 cm 99.21 - 10 cm 99.21 - 10 cm 99.21 - 10 cm 98.24 - 10 cm 98.82 - 10 cm 99.21 - 10 cm 98.04 - 10 cm 98.24 - 10 cm 99.80 - 10 cm 98.04 - 10 cm 98.24 - 10 cm 98.82 - 10 cm 99.02 - 10 cm 99.60 - 10 cm 99.21 - 10 cm 99.02 - 10 cm 98.63 - 10 cm 98.82 - 10 cm 99.02 - 10 cm 98.43 - 10 cm 98.24 - 10 cm 98.82 - 10 cm 98.82 - 10 cm 99.21 - 10 cm 98.43 - 10 cm 98.24 - 10 cm 97.65 - 10 cm 97.46 - 10 cm 97.65 - 10 cm 97.46 - 10 cm 97.85 - 10 cm 97.85 - 10 cm 97.85 - 10 cm 97.85 - 10 cm

that is what i get when i wave my hand quickly in front of the IR sensor

99.21 - 10 cm that is what it is if nothing is moving in front of it, also the thing is, the IR sensor doesn’t pick anything up if it is not moving

the baud rate wont work on 57.6 kbs, it will only work on 9600 for some reason :angry:

what is wrong :confused:

kj

please ignore the above post, i was using the wrong section of code :blush:

scratch that, i got the baudrate to go back to normal, and not im reading 510 and down, ill take another hand waving in front of the thing again

Left 508 Left 508 Left 511 Left 515 Left 514 Left 512 Left 508 Left 509 Left 510 Left 513 Left 509 Left 510 Left 513 Left 510 Left 511 Left 514 Left 512 Left 508 Left 509 Left 510 Left 512 Left 508 Left 508 Left 509 Left 510 Left 512 Left 488 Left 487 Left 489 Left 489 Left 488 Left 486 Left 487 Left 489 Left 488 Left 487 Left 488 Left 489 Left 488 Left 487 Left 489 Left 488 Left 486 Left 487 Left 489 Left 488 Left 486 Left 487 Left 489 Left 489 Left 488 Left 486 Left 487 Left 489 Left 488 Left 487 Left 488 Left 487 Left 489 Left 489 Left 488 Left 486 Left 487 Left 489 Left 488 Left 487 Left 488 Left 487 Left 489 Left 488 Left 487 Left 488 Left 487 Left 489 Left 489 Left 488 Left 486 Left 487 Left 489 Left 488 Left 487 Left 489 Left 488 Left 487 Left 489 Left 488 Left 487 Left 488 Left 487 Left 489 Left 488 Left 487 Left 488 Left 487 Left 489 Left 488 Left 487 Left 488 Left 487 Left 489 Left 489 Left 488 Left 486 Left 487 Left 491 Left 492 Left 492 Left 491 Left 492 Left 492 Left 492 Left 491 Left 493 Left 493 Left 493 Left 494 Left 496 Left 494 Left 495 Left 499 Left 500 Left 499 Left 501 Left 501 Left 501 Left 502 Left 503 Left 506 Left 507 Left 509 Left 511 Left 514 Left 512 Left 508 Left 508 Left 508

thats waving my handly slowly in and out of the range of the IR, but it still wont give me a solid value, my hand has to be in motion

:open_mouth:, now prepare yourselves, cause this is the really confusing part, i was playing around with the IR trying to get it to work, when, i accidently hit it and the IR comes unplggued…funny though, cause values kept coming up in Terminal 1 window, so i tested my theory and i clicks “Disconnect” then “connect” again, and it still gave me values :confused: :angry:

could someone shed some light on this? im at a complete lose here

:blush: :blush: :blush:

now PLEASE dont make fun of me for this,but when i wne to plug the IR back in, it worked, it has been on the wrong pins this whole time :blush: :blush: :blush: :blush: :blush: :blush:

anyway, now that that is figured out, ill be asking some quersions later, ty for eveynone that helped :blush:

:unamused:

LOLOL. Ohhh, let the onslaught of heckling and teasing begin. :slight_smile: :slight_smile:
Don’t worry, we all do it.

it was actually the way the baord is set up, the AUX pins are labeled one off from what they actually are, so while i was thikning i was on Pin 1, i was actually on Pin 2, look at your boards and you’ll see what i mean

Excuses, excuses. lol
:laughing:

:smiley: well, since i got the IR right, i have amde a simple code to learn how the IR works and see what i can do with it, right now if the sensor “sees” something about 7 inches away it turns away, waits 2 seconds, then goes back to a canstant postioston i set, not much, but its a start

[code]

left_detect var word

main:
adin ax2, 2, AD_RON, left_detect
serout S_OUT, i57600 ," Left ", dec left_detect, 13]

if left_detect >= 300 then
gosub servo_move
endif

goto main

servo_move
servo P0, 500
pause 2000
servo P0, -500
return[/code]

theres the code, lemme know whatcha think :slight_smile:

sounds cool
but if you want too servos to move at the same time
then ude the
pulsout/in command :astonished:

no, i dont need 2 to move at once

ok than your fine,
did you test the code yet?

The Basic Atom has hservo (or its brother) which can send a servo pulse to multiple servos at once.

cool
i had no idea
i was trying to find that out before :laughing:

yea, i have been, it works fine, but im working on it to turn left or right gradually until the IR ndoesn’t see w/e it is seeing anymore

oh wait
do you mean for the atom pro?