Shop OBEX P1 Docs P2 Docs Learn Events
light seeking program help — Parallax Forums

light seeking program help

noobmunchernoobmuncher Posts: 124
edited 2008-03-18 02:27 in BASIC Stamp
Hello, I am new to BS2 programing and i am looking for some help on a portion of my robots program that allows it to seek light.
I have a photo resister mounted on top of a rotating head (servo controlled) and i am trying to make the head turn the full rotation of the servo (all the way from left to all the way from right/ or preferably from center out each direction) and measure the light levels at say 4 different positions. Then depending on which area has the highest value go into driving in that direction. I have read this section in the Boe bot text except that is using multiple light sensors and to save I/0 ports i would prefer to use one and a servo. I will also use a modification of this program for PING object avoidance later on in my project.
So my question is how do i get it to record the light levels at 4 different positions and compare those 4 values to find the highest one?

Thanks for any help you provide!

Post Edited (noobmuncher) : 3/16/2008 9:27:18 AM GMT

Comments

  • UghaUgha Posts: 543
    edited 2008-03-16 12:24
    First... are you using a standard servo or a modified one?
    With a standard servo it'd be fairly easy... you can either store the four light levels in variables or in EEPROM.
    Just move the servo to point A then store the results of an RCTIME into a variable, then point B and so on.
    Later you can use a series of if statements to compare the variables.

    This method won't work with a continuous rotation (modified) servo though.
    I'm not sure which method would be best for a continuous rotation servo... I'm having a related problem with
    my robot as I only have continuous rotation servos, no standard ones.
    Perhaps a simple encoder wheel?
  • noobmunchernoobmuncher Posts: 124
    edited 2008-03-17 04:57
    I have standard servos so that should work thanks. Does IR sensors like http://www.parallax.com/Store/Components/Optoelectronics/tabid/152/CategoryID/30/List/0/SortField/0/Level/a/ProductID/178/Default.aspx
    and the sensor work well enough for object avoidance? Or do i have to have my robot fun into things with whiskers until i buy a proper distance detecting module. i got the idea from the Boe Bot "Robotics" textbook, even though i am not working with a Boe Bot.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-17 05:13
    The link you posted is for an IR LED, not a sensor. You can use this to generate an IR beam that you can detect with an IR detector.
    This is a typical detector for pulsed IR: www.parallax.com/Store/Components/Optoelectronics/tabid/152/CategoryID/30/List/0/SortField/0/Level/a/ProductID/177/Default.aspx.
    It works quite well for distance detection and object detection. The BoeBot manual has examples of this. Also look at IR Remote with the BoeBot.
  • noobmunchernoobmuncher Posts: 124
    edited 2008-03-18 02:27
    Okay thank you for the clarification of how well it works. Sorry i should have clarified, but was in a rush. I knew that that was just the IR bulb and i should have posted the sensor as well.
Sign In or Register to comment.