I got my hands on a V5 Vision Sensor and immediately tried it out. I first tried using the X and Y coordinates in a normal If/Else statement (With an offset value of course). It worked, but if I tried to make the robot go faster, it kept going into a left right left right loop.
Then I had an idea – I used code similar to the Arcade Control. I wrote a short piece of code that calculated the X and Y distance from a “zero” spot in the center of the Field of View, then inserted that as the motor speeds into a modified “Arcade Control”. Worked better than the previous If/Else.
Then I put this code inside an if statement, so you could normally drive the robot and then press a button if you wanted the robot to locate an object. Here have a look…