1 of 61

High Stakes

Programming

2 of 61

Agenda

Drivetrain

Motors

Controller

Block Coding

Intake Programming

Configuration

Programming Challenge

Programming Tips

3 of 61

Introduction

What is programming?

4 of 61

VEXcode V5

Two methods of Installation:

https://www.vexrobotics.com/vexcode/install/v5 - application

Scroll down and install for your system:

https://codev5.vex.com/ - online (not recommended)

5 of 61

Drivetrain

6 of 61

Drivetrain

7 of 61

Drivetrain

8 of 61

Drivetrain

How many motors do we have on the drivetrain?

9 of 61

Drivetrain

4 motor drivetrain

10 of 61

Drivetrain

Put in the ports of your left and right drivetrain motors.

Note: Ports shown may not be accurate to your robot

11 of 61

Drivetrain

No Gyro

12 of 61

Drivetrain

Click “Done”

13 of 61

Checkpoint

Click (devices button)

Click (add device button)

Click (4-motor drivetrain)

Put in left side drivetrain ports

Put in right side drivetrain ports

Click (no gyro button)

Click “Done”

14 of 61

Controller

15 of 61

Controller

16 of 61

Controller

17 of 61

Drive Mode

Arcade Mode:

Switch drive modes

18 of 61

Arcade Drive Mode

Arcade Mode:

  • left joystick for forwards/backwards movement
  • right joystick for turning movement

19 of 61

Checkpoint

Click (devices button)

Click (add device button)

Click (controller)

Click joystick icons until what is shown below

Click “Done”

20 of 61

Clamp

21 of 61

Clamp

22 of 61

Clamp

23 of 61

Clamp

Select port, change name, and select the 100 rpm cartridge.

Note: Ports shown may not be accurate to your robot

24 of 61

Clamp

Select port, change name, and select the 100 rpm cartridge.

Note: Ports shown may not be accurate to your robot

25 of 61

Checkpoint

Click (devices button)

Click (add device button)

Click (motor)

Put in the clamp port

Switch to 100 rpm gear cartridge (red)

Click “Done”

26 of 61

Intake

27 of 61

Intake

28 of 61

Intake

29 of 61

Intake

Select the ports of the intake.

Note: Ports shown may not be accurate to your robot

30 of 61

Intake

Configure the setting of the intake:

Rename 'MotorGroup' to 'Intake'.

Reverse one of the motors.

31 of 61

Checkpoint

Click (devices button)

Click (add device button)

Click (motor group)

Put in the intake motor ports

Switch one motors to be reversed

Click “Done”

32 of 61

Block Coding

33 of 61

Block Coding

Blocks in code represent actions the robot will take in real life.

Start spinning the Intake (to bring rings in).

Start spinning the Intake, but reversed (to push rings out).

Stop the intake.

Make the intake run at half the speed.

34 of 61

Blocks in code represent actions the robot will take in real life.

Block Coding

Drives the robot forward without stopping.

Drives the robot 12 inches forward.

Turns the robot right without stopping.

Turns the robot 90 degrees.

35 of 61

Variables in VEXcode store numbers.

Variables

36 of 61

Intake Programming

37 of 61

Intake Direction

intakeDirection variable

three states: reverse (-1), forward (1), and stopped (0).

38 of 61

Intake Direction

When the program starts running and driver control starts, we will set intakeDirection to 0, since the intake is stopped.

39 of 61

Checkpoint

Go to variables section on sidebar

Click (variable creation button)

Enter variable name

Set variable to 0 at the start of program & driver period

40 of 61

L1 - Intake Forward

Toggles the intake between forward and stopped states.

← Starts code inside of block when L1 is pressed.

← If the intake is spinning forwards,

← stop the intake, and

← set the intakeDirection to stopped state (0).

← If the intake is spinning any other direction,

← start spinning the intake forwards, and

← set the intakeDirection to forward state (1).

41 of 61

L2 - Intake Reverse

Toggles the intake between reverse and stopped states.

← Starts code inside of block when L2 is pressed.

← If the intake is spinning reverse,

← stop the intake, and

← set the intakeDirection to stopped state (0).

← If the intake is spinning any other direction,

← start spinning the intake reverse, and

← set the intakeDirection to reverse state (-1).

42 of 61

Question

Why do we need to stop the intake and set the intakeDirection variable to 0?

43 of 61

Intake Direction

Whenever you start or stop the intake, you must also set the variable.

The variable is how the robot knows whether the intake is stopped, spinning forwards, or spinning reversed.

44 of 61

Checkpoint

45 of 61

Configuration

46 of 61

Configuration

By default, the motors will be set to run at 50 RPM, no matter their max speed. We want to configure them to run faster.

We can use these blocks:

47 of 61

Configuration

Motors are able to have 3 types of stopping conditions:

Coast (default) - when motor is stopped, it will allow itself to slow to a stop, and it can move if something else moves it

Brake - when motor is stopped, it will stop in its position, but it can still move if something else moves it

Hold - when motor is stopped, it will stop in its position, and it will try to maintain its position

48 of 61

Configuration

Which stopping mode should we have for each set of motors?

  1. Intake
  2. Clamp
  3. Drivetrain

49 of 61

Configuration

Intake - coast, allows it to smoothly come to a stop

Clamp - hold, holds the mobile goal even when a button is not being pressed

Drivetrain - brake or hold, stops the drivetrain when an autonomous movement is complete

50 of 61

Configuration

← All configurations can be set in the “When Started” block.

51 of 61

Programming Challenge

52 of 61

Programming Challenge

Code a button to move the clamp while the button is pressed (hold button).

Hint: the blocks below may be helpful

Hint: click the "Help" button if you don't know what a block does

53 of 61

Autonomous Preview

54 of 61

Autonomous Preview

Try placing some of these blocks:

Under the when autonomous block.

55 of 61

Timed Run

To run the autonomous program you just coded:

  1. Download program
  2. Click on Programs (button A on controller)
  3. Click on the downloaded Program (slot 1, 2, etc, whatever you downloaded to)
  4. Click the right arrow
  5. Click A to select Timed Run
  6. Click A again to start the Timed Run
  7. Timed Runs will run the code in the "when autonomous" block

56 of 61

Programming Tips

57 of 61

Linking Controller

To link the controller to the brain:

  1. radio must be mounted and plugged in
  2. take out a wire from a motor and plug into controller
  3. wait until brain icon shows up on controller
  4. put wire back into motor

Read more in this VEX article.

Note: You should see a brain icon on your controller once it is linked.

58 of 61

Connecting Laptop

To download to brain or controller, you will need a USB-A to MicroUSB cable (in electronics box).

If you are using a device that only has USB-C (like a Mac), you must get a converter from USB-A to USB-C.

USB-A to MicroUSB cable

59 of 61

Downloading to Brain

Two methods to download:

  1. Connect laptop to brain
    1. Click download
  2. Connect laptop to controller
    • Brain must be linked to controller
    • Controller & brain icons in VEXcode should be green
    • Click download

Read more in this VEX article.

Note: You should see a brain icon on your controller once it is linked.

60 of 61

Controller Frozen

Controller can get frozen, where it doesn't respond to button presses.

To fix this:

  1. Unplug any wire going into controller
  2. Put screwdriver into hole in the back of the controller
  3. Wait for it to reboot

Read more in this VEX article.

61 of 61

Q/A