Shop OBEX P1 Docs P2 Docs Learn Events
The problem about light sensor — Parallax Forums

The problem about light sensor

AnnAnn Posts: 9
edited 2014-04-23 09:39 in Learn with BlocklyProp
1.png
2.png
3.png

what differences between these three tiles?
If I want to use GUI program to realize Light Seeking Behavior, what should I do ? Is there anyone could give me a sample program ?
179 x 151 - 3K
179 x 151 - 4K
179 x 151 - 4K

Comments

  • Steph LindsaySteph Lindsay Posts: 767
    edited 2014-04-23 09:09
    Hi Ann,

    Have you looked at the Scribbler Help? Click on the [?] button on the toolbar. Then, in the Table of Contents, look under Conditional Tiles for Light Sensor Condition.

    I have not played with the light sensors that much. But, going from the Help file, I think this is what the tiles mean. (The software's author, PhiPi, is active on this forum and I hope he corrects me if I'm wrong!!)

    In the picture above, the leftmost picture says "the lefthand light sensor must return a value of at least 1 for the condition to be true." Since it is the only dot in the blue box, the condition is only paying attention to the leftmost light sensor, and the states of the other two do not matter. You can adjust that number from 1 to 255 by using a slider bar when configuring the tile.

    In the other two pictures, all three dots are in the blue box, so I'll assume the values returned by all three light sensors are used to evaluate the condition. In each picture, one dot is different from the other two. So, I believe the dot that is different is the focus of the condition.

    The middle picture would be saying "the leftmost sensor must be the brightest by 1." The rightmost picture would be saying "the rightmost sensor must be the dimmest by 1." Again, the slider would be used to adjust that range from 1 to 255.

    Phil, am I close?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-04-23 09:26
    You're spot on, Steph!

    The best way to tell for sure what a tile is doing is to look at the Spin code it produces. Here's the code output for the three tiles shown:

    attachment.php?attachmentid=108285&d=1398235941&thumb=1 if (LeftLight => 1)

    attachment.php?attachmentid=108286&d=1398236010&thumb=1 if (LeftLight - CenterLight => 1 and LeftLight - RightLight => 1)

    attachment.php?attachmentid=108287&d=1398236052&thumb=1 if (LeftLight - RightLight => 1 and CenterLight - RightLight => 1)

    -Phil
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2014-04-23 09:39
    Thanks so much Phil, that really clarifies things!
Sign In or Register to comment.