TRINITY ROBOTICS

Introduction 1: Brain Power

Every robot needs a brain (to control the robot program) and a battery (to provide power).

You will need the following items:

  • VEX V5 Brain
  • VEX V5 Battery
  • Battery Cable (to connect the battery to the brain)
  • Micro USB Cable (to connect the brain to the computer)

Be extremely careful plugging in and unplugging the Micro USB connector from the V5 Brain.  The cable only fits one way and this port can be easily broken.

We will be using VEXcode V5 software to program our robots.  It is found online at https://codev5.vex.com/.

Challenge:

Let’s write our first program.  In the FILE menu, select “NEW BLOCKS PROJECT“.  Click on the “VEXcode Project” button and change the file’s name to “MakingShapes“.

button1

To write a program, drag blocks from the library on the left and drop them onto the yellow “WHEN STARTED” block in the workspace.  If you don’t know what a block does, you can always click on the “?” button and then click on one of the blocks to get help.

button2

If you do this with the “DRAW RECTANGLE” block, you will see that block requires four values (x, y, w, h):

  • Value 1: the top-left corner X coordinate
  • Value 2: the top-left corner Y coordinate
  • Value 3: the width of the rectangle
  • Value 4: the height of the rectangle

It also explains how to change the color of the outside border and the inside fill color.

TASK 1:

Completely fill the screen with a blue rectangle.

The screen is 480 pixels (screen dots) wide and 240 pixels high.  People start counting from 1 (1, 2, 3…) but computers always start counting from 0 (0, 1, 2…).  So instead of drawing a rectangle from pixel 1 to 480, you would start at 0 and go to 479.  Do the same thing for the height.

TASK 2:

Make it an orange rectangle.  Change the program so that it waits for you to touch the screen before the rectangle appears.

When you use sensors (and the brain’s touch screen is a sensor), it is best to put them in a WAIT UNTIL block rather than an IF-THEN-ELSE block.  IF-THEN blocks only check the condition one time and then move on.  To check the sensor more than once, you would have to put the blocks into a LOOP.  By using a WAIT UNTIL block, the program will stop there and keep checking the sensor until the condition becomes TRUE.  Then it moves on to whatever comes next in the program.