High Stakes
Programming
Agenda
Drivetrain
Motors
Controller
Block Coding
Intake Programming
Configuration
Programming Challenge
Programming Tips
Introduction
What is programming?
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)
Drivetrain
Drivetrain
Drivetrain
Drivetrain
How many motors do we have on the drivetrain?
Drivetrain
4 motor drivetrain
Drivetrain
Put in the ports of your left and right drivetrain motors.
Note: Ports shown may not be accurate to your robot
Drivetrain
No Gyro
Drivetrain
Click “Done”
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”
Controller
Controller
Controller
Drive Mode
Arcade Mode:
Switch drive modes
Arcade Drive Mode
Arcade Mode:
Checkpoint
Click (devices button)
Click (add device button)
Click (controller)
Click joystick icons until what is shown below
Click “Done”
Clamp
Clamp
Clamp
Clamp
Select port, change name, and select the 100 rpm cartridge.
Note: Ports shown may not be accurate to your robot
Clamp
Select port, change name, and select the 100 rpm cartridge.
Note: Ports shown may not be accurate to your robot
Checkpoint
Click (devices button)
Click (add device button)
Click (motor)
Put in the clamp port
Switch to 100 rpm gear cartridge (red)
Click “Done”
Intake
Intake
Intake
Intake
Select the ports of the intake.
Note: Ports shown may not be accurate to your robot
Intake
Configure the setting of the intake:
Rename 'MotorGroup' to 'Intake'.
Reverse one of the motors.
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”
Block Coding
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.
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.
Variables in VEXcode store numbers.
Variables
Intake Programming
Intake Direction
intakeDirection variable
three states: reverse (-1), forward (1), and stopped (0).
Intake Direction
When the program starts running and driver control starts, we will set intakeDirection to 0, since the intake is stopped.
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
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).
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).
Question
Why do we need to stop the intake and set the intakeDirection variable to 0?
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.
Checkpoint
Configuration
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:
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
Configuration
Which stopping mode should we have for each set of motors?
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
Configuration
← All configurations can be set in the “When Started” block.
Programming Challenge
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
Autonomous Preview
Autonomous Preview
Try placing some of these blocks:
Under the when autonomous block.
Timed Run
To run the autonomous program you just coded:
Programming Tips
Linking Controller
To link the controller to the brain:
Read more in this VEX article.
Note: You should see a brain icon on your controller once it is linked.
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
Downloading to Brain
Two methods to download:
Read more in this VEX article.
Note: You should see a brain icon on your controller once it is linked.
Controller Frozen
Controller can get frozen, where it doesn't respond to button presses.
To fix this:
Read more in this VEX article.
Q/A