WeBots Simulator Light Sensor Robot

Could anyone help me with being able to control the motors on the robot to guide it towards the light?
I can only get it to go in a straight line and not direct to the light.

Try creating helper functions turnL() turnR().
Then check values of two eyes.

Pseudocode:

if moreLightOnTheLeft:
  turnL()
elif moreLightOnTheRight:
  turnR()
else:
  forward()

Coding a turning function should be easy, just set one motor speed to 0.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.