Answers.Body: <pre><code>In pseudocode:
  
  LoopBlock (forever)
      MoveBlock (B and C motors, 75% power, forward, forever)
      -- unclear here, probably want to head for brighter light
      -- instead, just wait for 80%
      If LightSensorBlock (port 3, greater than, threshold 80%) Then
           MoveBlock (B and C motors, stop)
           WaitForBlock (time, 10 seconds)
      End If
  End Loop
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-04-22T21:46:18.637Z
Answers.Text: I want my robot to follow the light.To track where there is light. when the brightness is more than 80% to stop and to move a third motor 30 degrees.
Answers.UserDisplayName: vadim
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-04-22T22:33:06.603Z
Answers.Text: i thing that its beter to use two light sensor to rotate my motors.
Answers.UserDisplayName: vadim
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-04-23T00:53:33.003Z
Answers.Text: "two light sensors to rotate my motors"?  I'd suggest using just one light sensor and getting that to work before jumping to two.
Answers.UserDisplayName: dfrevert
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-04-23T00:56:35.043Z
Answers.Text: One light sensor pointed forward suggests that the robot should at regular intervals, stop turn right, turn left, and compare those light sensor values and compare to make sure the robot is still headed in the right direction. Start with just that.  Spinning in a circle and finding the brightest value would be a next step.
Answers.UserDisplayName: dfrevert
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-04-23T01:25:47.827Z
Answers.Text: I made that with the spinning.my problem is that i cant do my robot to turn in to the light beam of light.i manage to start when it realize the light or to stop.but it cant turn right or left in the beam.
Answers.UserDisplayName: vadim
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-04-23T01:29:55.437Z
Answers.Text: if i use two sensors and compare the values of the light beam i thing its more easy.if you think something let me know.
Answers.UserDisplayName: vadim
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-04-22T21:34:18.443Z
Answers.LastActivityDate: 2014-04-22T21:34:18.443Z
Answers.UserDisplayName: dfrevert
Answers.Body: <pre><code>#pragma config(Sensor, S3,     lightSensor,         sensorLightActive)
  //*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
  
  
  task main()
  {
     wait1Msec(50);                        // The program waits 50 milliseconds to initialize the light sensor.
  
     while(true)                           // Infinite loop
     {
        if(SensorValue(lightSensor) &lt; 45)  // If the Light Sensor reads a value less than 45:
        {
          motor[motorB] = 0;                  // Motor B is run at a 0 power level.
          motor[motorC] = 30;                  // Motor C is run at a 30 power level.
        }
        else                               // If the Light Sensor reads a value greater than or equal to 45:
        {
          motor[motorB] = 50;                  // Motor B is run at a 50 power level.
          motor[motorC] = 50;                  // Motor C is run at a 50 power level.
          while (SensorValue(lightSensor) &gt;80) // If the Light Sensor reads a value MORE than 80:
  
  {
  
    motor[motorC] = 0;  
  
    motor[motorB] = 0;
    motor[motorA] = 10;
  
  }
  
        }
     }
  }
  </code></pre>
  
  <p>Finally I got it done!!!!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-05-02T12:37:51.313Z
Answers.Text: This always turns right if there's not enough light. I'd suggest that when you lose the light source your robot should: 1 turn left a bit, 2 store the current light value, 3 turn right twice of the amount in step1, 4 check if the current light value is higher or lower than the stored one. If higher than the light is probably to the right side, so it can just go forward. But if the stored value is higher, you need to turn back to the left the same amount as in step3 and keep going that way.
Answers.UserDisplayName: zovits
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-04-23T16:11:09.253Z
Answers.LastActivityDate: 2014-04-24T13:21:46.763Z
Answers.LastEditDate: 2014-04-24T13:21:46.763Z
Answers.UserDisplayName: vadim
Body: <p>I use Lego Mindstorms NXT 2.0. I want to schedule my robot to move to where there is light αnd then when it finds it (a large amount of light, for example 80%) to stop and move another motor for 30 degrees. Then stay still for 10 seconds and after that to search for another light.</p>
  
  <p>Can you help me please?</p>
  
  <p>I use</p>
  
  <p>port B: right motor</p>
  
  <p>port C: left motor</p>
  
  <p>port A: the degrees motor</p>
  
  <p>port 3: a light sensor</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-04-22T21:30:03.620Z
Comments.Text: Is the light sensor pointed forward?, down?, on a turntable?
Comments.UserDisplayName: dfrevert
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-04-22T21:47:54.217Z
Comments.Text: forward.for example I want ιτ to follow a lens
Comments.UserDisplayName: vadim
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-04-23T12:09:02.377Z
Comments.Text: Depending on the design of your robot, you may not need the third motor. Just move the left and right motor in opposite directions.
Comments.UserDisplayName: S.L. Barth is on codidact.com
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-04-23T12:16:52.183Z
Comments.Text: no..the third motor I want it for other use.how to move the motors in the light beam with one sensor?it is not difficult to make my robot to turn.it is difficult to turn into the light.
Comments.UserDisplayName: vadim
Tags: <nxt><mindstorms>
Title: Robot that searches for lights
UserDisplayName: vadim
ThreadText: # Robot that searches for lights
  
  (Asked by: username_0 on 2014-04-22)
  
  I use Lego Mindstorms NXT 2.0. I want to schedule my robot to move to where there is light αnd then when it finds it (a large amount of light, for example 80%) to stop and move another motor for 30 degrees. Then stay still for 10 seconds and after that to search for another light.
  
  Can you help me please?
  
  I use
  
  port B: right motor
  
  port C: left motor
  
  port A: the degrees motor
  
  port 3: a light sensor
  
  **Tags:** nxt, mindstorms
  
  > **Comments:**
  > **username_1**: Is the light sensor pointed forward?, down?, on a turntable?  
  > **username_0**: forward.for example I want ιτ to follow a lens  
  > **username_2**: Depending on the design of your robot, you may not need the third motor. Just move the left and right motor in opposite directions.  
  > **username_0**: no..the third motor I want it for other use.how to move the motors in the light beam with one sensor?it is not difficult to make my robot to turn.it is difficult to turn into the light.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-04-22. Score: 1
  
  ```
  In pseudocode:
  
  LoopBlock (forever)
      MoveBlock (B and C motors, 75% power, forward, forever)
      -- unclear here, probably want to head for brighter light
      -- instead, just wait for 80%
      If LightSensorBlock (port 3, greater than, threshold 80%) Then
           MoveBlock (B and C motors, stop)
           WaitForBlock (time, 10 seconds)
      End If
  End Loop
  
  ```
  
  > **Comments:**
  > **username_0**: I want my robot to follow the light.To track where there is light. when the brightness is more than 80% to stop and to move a third motor 30 degrees.  
  > **username_0**: i thing that its beter to use two light sensor to rotate my motors.  
  > **username_1**: "two light sensors to rotate my motors"?  I'd suggest using just one light sensor and getting that to work before jumping to two.  
  > **username_1**: One light sensor pointed forward suggests that the robot should at regular intervals, stop turn right, turn left, and compare those light sensor values and compare to make sure the robot is still headed in the right direction. Start with just that.  Spinning in a circle and finding the brightest value would be a next step.  
  > **username_0**: I made that with the spinning.my problem is that i cant do my robot to turn in to the light beam of light.i manage to start when it realize the light or to stop.but it cant turn right or left in the beam.  
  > **username_0**: if i use two sensors and compare the values of the light beam i thing its more easy.if you think something let me know.  
  
  ---
  
  ### Answer by username_0 on 2014-04-23. Score: 0
  
  ```
  #pragma config(Sensor, S3,     lightSensor,         sensorLightActive)
  //*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
  
  task main()
  {
     wait1Msec(50);                        // The program waits 50 milliseconds to initialize the light sensor.
  
     while(true)                           // Infinite loop
     {
        if(SensorValue(lightSensor) < 45)  // If the Light Sensor reads a value less than 45:
        {
          motor[motorB] = 0;                  // Motor B is run at a 0 power level.
          motor[motorC] = 30;                  // Motor C is run at a 30 power level.
        }
        else                               // If the Light Sensor reads a value greater than or equal to 45:
        {
          motor[motorB] = 50;                  // Motor B is run at a 50 power level.
          motor[motorC] = 50;                  // Motor C is run at a 50 power level.
          while (SensorValue(lightSensor) >80) // If the Light Sensor reads a value MORE than 80:
  
  {
  
    motor[motorC] = 0;  
  
    motor[motorB] = 0;
    motor[motorA] = 10;
  
  }
  
        }
     }
  }
  
  ```
  
  Finally I got it done!!!!
  
  > **Comments:**
  > **username_3**: This always turns right if there's not enough light. I'd suggest that when you lose the light source your robot should: 1 turn left a bit, 2 store the current light value, 3 turn right twice of the amount in step1, 4 check if the current light value is higher or lower than the stored one. If higher than the light is probably to the right side, so it can just go forward. But if the stored value is higher, you need to turn back to the left the same amount as in step3 and keep going that way.  
  
  ---
  
  