Hi, I'm relatively new to arduino and coding, I picked it up as an interest and so far I've been enjoying it even though it's been pretty basic stuff. Now I've wanted to try something more advanced/tricky. I want to use a Sharp GP2Y0A21YK IR Proximity sensor to trigger two continuous servo motors (Parallax). I've managed to get the two servo's moving in one direction, but i have no clue where to start or if im doing something wrong.
I figured that's what main was. thanks though. I tried the pseudo-code out but i couldnt get it to work, like servos move foward and everything but it wont respond to the sensor. might be a hardware issue i guess? either that or im messing up somewhere.
Oh i know that. I used it as a guideline.
here's the code. I did some changes to it because it was giving me errors.
so If something seems off, its because of me.
ok. let me respond to Groove first. My intention for this project is to get the sensor to trigger the servos to move. the problem I'm having is that the servos rotate non stop without the trigger. so either the sensor is not working the way it should or I'm not sure what else. I know the sensor isnt dead or defective since i tried it out just to see if it was before.
now to newbie. when i open up the serial monitor i get one number, literally just one since no other value prints there after. and each time i reopen the serial monitor i get a new value. basically i get a single random value each time ranging from the 100's to 3000's.
not sure if I've answered the questions correctly but, oh well. I'm literally a complete newbie.
Also, difficult to see how an analogueRead returns 3000.
Cut out all the servo driving stuff and concentrate on getting the sensor readings looking sensible, just using prints. Tackle one thing at a time.
[edit] Let's be clear on one thing; whatever they were described or sold as, those are not servos.
How are you powering them? Not from the Arduino, I hope [/edit]
oh no, of course not. I figured that the arduino wouldn't be able to power them. they're being powered externally by a 9v battery pack, which seems to be working fine. although they drain the battery pretty fast, but thats expected.