Vision Sensor
Train the Sensor
(Never use premade/default color settings...always define your own.)
Ask Mr. Harrington to set up a "White Background & Base " for you. This will help you Train the Sensor to recognize the Pure Colors.
- Open VexCode V5 Block
- Connect the Vision Sensor with a USB cable to your computer.
- Open the Device Menu, and select: "Add A Device" / Vision / Port (match with Brain port) / Title it (see 3a. below) / Configure.
- Title the Device: You will be blocked from using standard color names like "Yellow." So, make up your own color titles (Eg."Yll" instead of Yellow.).
(A green light should appear on Vision Sensor when a connection is made. Also, you will see its view appear on the Device Menu Monitor. If it does not appear, check your connections, cables and it does not work well on Macs.)
- Aim Sensor at colored object.
- Press "Freeze."
- Click and drag a square over the object.
- Check "Set". You will see Transparent Cover over the object.
- If there is not much coverage, use the "Slider" to increase or decrease coverage. The goal is to have the 'Fog' cover the object's color and nothing else.
- You may want to move the object closer to the Vision Sensor to activate the "Set" boxes (Green!).
- Select Freeze a second time...this will unfreeze the screen.
- Saving? There is no Save Button...so close the window and it will save it to the actual Vision Sensor.
- Also, select "Done" prior to leaving the Device Menu. This is necessary, or else your changes will not be applied to your program.
- Always "Save" prior to quitting the VexCode V5 Blocks program.
Program the Robot/Sensor.
Rule: Always start simple until you achieve Success...and then build upon your Simple success!
- Write a very simple program that tests just one color. (I recommend Yellow or Orange), and then do the other colors. If a color like Purple does not work...go back to the Device Menu and reset the Vision Sensor to be able to see the color.
- Note: stack the colored blocks and cones exactly 4 cones/blocks high.
- When it works, then begin writing the same program for the other colors.
- When you have successfully written a program for each color, now combine all of them into one program.
Programming Hints:
Program 1: Based on Heights (I set at 100 - 160). As the robot approaches the wall of colored blocks, the height of the color increases and at a specific height, the robot stops and goes in reverse. Since I had difficulty with the color Purple, I used "Center X" (1) instead of Height. Explanation of "Object: Height/Width/CenterX." Program 2: The robot would proceed forward until it saw one of the Defined Colors. At that moment, it would stop, reverse, turn and proceed. Explanation of "Objects exists." Note:
- If the robot immediately doesn't move forward but begins the "If/Then"...then change the 'Distance' to the Height or Center X.
- Also, the distance has a Sweet Spot. Eg: "85-120." Any amount outside of the Sweet Spot and you won't see any change in performance.