Archive for the ‘vex’ tag
Controlling the Brightness of the VEX Flashlight
The VEX Flashlight is an awesome accessory that will let your robot “lighten up” any situation it’s in.
Cheesy puns aside, the VEX Flashlight contains four bright LED’s – useful for lighting up a dark environment, keeping constant light on an object or line the robot is tracking, or any number of other possible applications.
One of the limitations of the two-wire flashlight, though, is that its brightness cannot be controlled by the standard 3-wire MOTOR ports on the VEX PIC or VEX Cortex. In today’s post, we’ll overcome that limitation using one of the VEX Motor Controllers.
In the picture below, the VEX Flashlight is connected to MOTOR Port 2 on the Cortex using one of the VEX Motor Controllers. Also attached are a light sensor to measure the amount of light provided by the flash light in the ROBOTC Debugger, and a potentiometer to enable us to vary the amount of light.
In the sample program below, we use feedback from the potentiometer to control the brightness of the flashlight. The potentiometer provides values between 0 and 4095 on the Cortex, so we have to scale that down by a factor of 32 to stay within the range of values the Flashlight will accept (0 to 127). Note also, that in the configuration pragma statements, the flashlight is configured as a “reversed” motor; it actually accepts values ranging from 0 to -127. Reversing it allows us to give it more intuitive, positive values.
#pragma config(Sensor, in1, light, sensorReflection)
#pragma config(Sensor, in2, potentiometer, sensorPotentiometer)
#pragma config(Motor, port2, flashlight, tmotorNormal, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
while(true) //Loop Forever
{
//Set the power of the flashlight equal to a scaled value from the potentiometer
motor[flashlight] = SensorValue[potentiometer]/32;
//Divide by 32 on the Cortex, since the potentiometer values are 0 - 4095
//Divide by 8 on the PIC, since the potentiometer values are 0 - 1023
}
}
Check out this video of the brightness control in action:
YouTube Direct Link VEX Flashlight - Brightness Control
In case you want to try this out, but don’t have a potentiometer, here’s more sample code that just cycles through different brightness values, over and over. You can see that programming the VEX Flashlight works basically the same as programming a motor.
#pragma config(Sensor, in1, light1, sensorReflection)
#pragma config(Motor, port2, flashlight, tmotorNormal, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
//Loop Forever
while(true)
{
//Turn off flashlight for 2 seconds
motor[flashlight] = 0;
wait1Msec(2000);
//Turn on flashlight at 1/4 brightness for 2 seconds
motor[flashlight] = 31;
wait1Msec(2000);
//Turn on flashlight at 1/2 brightness for 2 seconds
motor[flashlight] = 63;
wait1Msec(2000);
//Turn on flashlight at 3/4 brightness for 2 seconds
motor[flashlight] = 96;
wait1Msec(2000);
//Turn on flashlight at full brightness for 2 seconds
motor[flashlight] = 127;
wait1Msec(2000);
}
}
Controlling Pneumatic Actuators in ROBOTC
Pneumatic Actuators translate the force of compressed air into fast and powerful motion. In the VEX Robotics System, all pneumatic actuators create linear (in-and-out) motion, although rotary actuators do exist. The compressed air that powers the actuators is stored in a reservoir tank; differences in air pressure between the actuators and tank cause the actuators to move in and out.
The flow of air between the tank and the actuators (directly related to the differences in air pressure) is controlled by a small switch, called an electromagnetic solenoid, which connects to the VEX PIC or Cortex using a standard 3-pin wire. It’s a common misconception that, since the solenoid enables motion, its 3-pin wire should plug into one of the MOTOR ports on the microcontroller. Actually, a solenoid is what’s considered a “Digital Output”, and should be plugged into one of the DIGITAL ports on the Cortex, or ANALOG/DIGITAL ports on the PIC.
To configure the solenoid in ROBOTC, go to the Motors and Sensors Setup menu, and select “Digital Out” as the sensor type.

Then, in ROBOTC, when you want to activate the pneumatic actuator controlled by the solenoid, you set its value equal to “1″. To deactivate it, set its value equal to “0″. In the sample code below, the remote control buttons are used to activate and deactivate the pneumatic actuator.
#pragma config(Sensor, dgtl7, solenoid, sensorDigitalOut)
//*!!Code automatically generated by ‘ROBOTC’ configuration wizard !!*//
task main()
{
while(true) // Loop Forever
{
if(vexRT[Btn6U] == 1) // If button 6U (upper right shoulder button) is pressed:
{
SensorValue[solenoid] = 1; // …activate the solenoid.
}
else // If button 6U (upper right shoulder button) is NOT pressed:
{
SensorValue[solenoid] = 0; // ..deactivate the solenoid.
}
}
}
For more information on using pneumatic actuators, check out our Pneumatics lesson from the VEX 2.0 Curriculum.
Traversing a Grand Challenge with the VEX Cortex
The Grand Challenge is a staff designed course which is not revealed to participants until the day of the competition. Before the competition, participants are provided with a list of conditions and situations to prepare their robots for.
On the day of the competition, the participant’s programming knowledge and preparation are put to the test as they work to traverse the course in a limited amount of time. The robot that makes the most progress without stalling out or deviating from the course wins!
In this iteration of the Grand Challenge, the Cortex-based robot must:
- Navigate an obstructed path using feedback from the Shaft Encoders and Ultrasonic Rangefinder
- Track an incomplete line up and down a ramp using feedback from the Line Tracking sensors
- (Optional) Pick up the yellow ball and take it to the finish zone for extra points
- Respond to remote-control commands only in the final zone
- Avoid hitting obstacles in it’s path, walls on the field, and falling from the ramp
Check out this cool video of the robot completing the course.
To accomplish it’s task, the Cortex-based robot is equipped with:
- Two driving motors, each with a Shaft Encoder
- An Omni-wheel acting as a rear-caster wheel
- Three Line Tracking Sensors
- An Ultrasonic Rangefinder
- Remote Control over VEXnet
Instructions for building this robot can be found here.
If you’d like ideas for creating your own Grand Challenge, check out this document for some inspiration.
Note: All materials are part of the VEX Cortex Video Trainer. Check it Out!
BEST Competition Programming Templates
Hey all BEST Teams!
We’ve made a new library and sample program to help BEST teams up and running with using ROBOTC with their Cortex systems. This new template makes it really easy to customize your program for your robot without having to worry about loops, conditionals and variables too much. Here’s an example of some of the new functions.
- ArcadeTwoWheelDrive(vexJSLeftV, vexJSLeftH, left, right);
- Use this function to create a “arcade” (1 joystick) drive program. Pass 4 pieces of data to have the function do all the work for driving your robot.
- 1st: MoveChannel – The joystick channel for forward and reverse.
- 2nd: RotateChannel – The channel on the rotate port that controls left and right rotation. This value is mixed with the move channel.
- 3rd: leftMotor – The motor on the left side of the robot.
- 4th: rightMotor – The motor on the right side of the robot.
- Use this function to create a “arcade” (1 joystick) drive program. Pass 4 pieces of data to have the function do all the work for driving your robot.
- TankTwoWheelDrive(vexJSLeftV, vexJSRightV, left, right);
- Use this function to create a “tank” (2 joystick) drive program. Pass 4 pieces of data to have the function do all the work for driving your robot.
- 1st: MoveChannel – The joystick channel for “left” motor.
- 2nd: RotateChannel – The joystick channel for “right” motor.
- 3rd: leftMotor – The motor on the left side of the robot.
- 4th: rightMotor – The motor on the right side of the robot.
- Use this function to create a “tank” (2 joystick) drive program. Pass 4 pieces of data to have the function do all the work for driving your robot.
- MotorControlViaDigitalButtons(Btn7D, Btn7U, leftArm, -127, +127, 0);
- Use this function to control a motor via two digital buttons – Very customizable!
- 1st: Btn7D – The joystick button that controls speed decrease
- 2nd: Btn7U – The joystick button that controls speed increase
- 3rd: leftArm – The motor that is being controlled
- 4th: -127 – The lowest value for the motor speed
- 5th: +127 – The highest value for the motor speed
- 6th: 0 – How fast to adjust the speed. 0 — fastest. 50 — 1.25 seconds to cover the compete range.
- Use this function to control a motor via two digital buttons – Very customizable!
Download this new library and sample program today. To help you get started, we’ve written a “getting started” PDF that will help you get started with this library.
FREE ROBOTC Webinar available for viewing!
Hi everyone!
Our very own VEX expert, Jesse Flot, has just recently recorded a webinar to help those using the CORTEX platform. Starting yesterday (Sept. 8th), Jesse will be recording weekly webinars (for 6 weeks) to help those who are looking for resources when working with the CORTEX system.
Jump to the Webinars area to view it
Please note that this webinar epsiode is geared towards the BEST competition, but that doesn’t mean that it won’t help you out.
The way that the webinars will be created is Jesse will take questions from the CORTEX Competition forum, and use those topics to record a webinar.
If you wish to submit a topic to talk about, please log onto the forum and post a topic!
ROBOTC for Cortex and PIC 2.25 released!
The Robotics Academy is happy to announce the release of ROBOTC for Cortex 2.25.
We’ve made lots of changes in ROBOTC from 2.20 to 2.25. We’re continuing to improve ROBOTC with the Cortex system. This new version is fully compatible with the VEX Cortex and the VEX PIC systems, along with the VEXnet upgrade system for the VEX PIC.
Click here to download the latest version
Firmware Downloader Built-In: Firmware Download for ROBOTC Firmware, Cortex Master Firmware and VEXnet Joystick Firmware built into ROBOTC now!
Download Method Chooser: Easier to choose how you want to download your program. Always defaults to VEXnet and USB, but you can manually choose to disable VEXnet and download over USB only.
Quick Preferences: This allows you to set key preferences with only the click of a button. Make ROBOTC work the way you want it to!
Other New Features and Bug Fixes:
- Build is able to program both PIC and Cortex platforms successfully.
- “Auto save” before compile was broken.
- “Previous Platform Type” was not being correctly saved into Windows Registry.
- Add code to handle “Device Removal” and “Device Acquire” without long hangs of application.
- Added a flag to Preferences -> Internal” to indicate whether firmware downloading should be read verified.
- Fix “Priority” column in “Task Status” debugger pane. It was not properly displaying.
- Move “Debug Stream” from Super-User to “Expert” menu.
- Add a 250 millisecond delay after telling Cortex to enter download mode before attempting the autobaud sequence.
- VEX Cortex Integrated Master Firmware Loader inside of ROBOTC.
- Add support for run-time strings in the VEX LCD display routines.
- Fix conlict between Digital pin 4 and 10. They both share the same external interrupt index and it was possible to hang the Cortex. Fix makes both pins work correctly — previously pin 10 was not working — for external interrupts. But the hardware prevents supporting sensors that require external interrupts on both pins at once.
Want to be in the loop? Sign up to our mailing list!
Hello fellow ROBOTC fans!
I just created a ROBOTC Mailing list for those of you who like to be in the “in” crowd.
Just go to www.robotc.net and type in your Name and Email address on the right side. Subscribe by clicking the “Subscribe” button, unsubscribe by clicking the “unsubscribe” button.
I’ll update you on when a new release or beta version is out. Or if any important information regarding ROBOTC needs to be announced.
Happy programming!
New Cortex online class! Fall 2010 Teacher Training Schedule released!
Greetings Educators!
The Robotics Academy has set some Online Teacher Training Dates for the Fall. The classes include the ROBOTC for LEGO/TETRIX and our brand new class: The ROBOTC for Cortex online class.
Here are the schedules for the Fall Online Teacher Training:
- ROBOTC for LEGO/TETRIX
- Begins October 6th, 2010 – Every Wednesday for 6 weeks
- Click here for more details about ROBOTC for LEGO/TETRIX
- ROBOTC for Cortex – NEW!
- Begins October 5th, 2010 – Every Tuesday for 6 weeks
- Click here for more details about ROBOTC for Cortex
Click here to take a look at all of the classes we have to offer!
FREE ROBOTC download for training, and more!
ROBOTC available as FREE download for training this summer
The teams have spoken!
Three out of four teams at the FTC national championships programmed their prize-winning robots with ROBOTC this year.
Thanks to its real-time debugger, optimized code, free online training materials, and large forum support community, ROBOTC is quickly becoming the language of choice for the robotics competition community.
The Robotics Academy supports teams competing in ROBOFEST, the National Robotics Challenge, FTC, and the VEX competition, just to name a few. And, this summer only, you can train with it for FREE!

Go to ROBOTC for Mindstorms to register to receive a free copy of ROBOTC that you can load onto either your personal computer or a classroom set of computers for training teachers and students to program LEGO and TETRIX robots this summer.
Go to ROBOTC for IFI to register to receive a free copy of ROBOTC to prepare teachers and students to program with VEX and Cortex robots.
Feel free to pass these links on to students, teachers, and hobbyists!
Teacher training at Carnegie Mellon’s Robotics Academy is filling fast!
Over the last five years over one thousand teachers from across the United States have come to Carnegie Mellon to receive training straight from the experts at the Robotics Academy. Remaining spots are filling fast!
To find out more about these classes, click here!
Can’t make it to Pittsburgh this year? Check out our online summer courses! Each course provides guided instruction with live instructors, using internet voice, video, and screen sharing technology to bring high-quality robotics instruction directly to your home, office, or classroom.
FREE Download: ROBOTC for Cortex BETA 2.16 available
Hi again,
ROBOTC for Cortex BETA 2.16 has just been uploaded to the servers. Click here to download it!
Here are the changes:
- Trial extended to 9/31/2010 – Yay!
- More accurate feedback from the Accelerometer in the game controller
- Fixes an issue where ROBOTC was overloading the 2-wire H-Bridge motor ports when switching the from forward to reverse directions.
- Various bug fixes
Hope you enjoy it!
By the way, Cortex hardware is now available for Pre-Order at the Robomatter Robotics Education store.
Be the first to get it!










