How do I create a program for programming skills with RobotC? I can’t find a specific code file that can be used for programming skills. My team has our competition code, with an autonomous and a user-control. Does the programming skills program go in the same file, or in a different one? If it goes in a different one, then does it have to go into a specific type of file, and, if so, how do I create it?
Use the competition template and put your code in the autonomous part only.
Use something like a potentiometer to select between auton modes and skills. Same file, just inside of a “selector” function.
Something like this:
task autonomous()
{
switch(round((1/2700)*SensorValue[SP]))
{
case 0: //RED
switch (round((3/2700)*SensorValue[OP]))
{
case 0:
break;
case 1:
break;
case 2:
break;
default:
}
break;
default: //BLUE
switch (round((3/2700)*SensorValue[OP]))
{
case 0:
break;
case 1:
break;
case 2:
break;
default:
}
}
}
Even better, use an LCD.
@mwang17 This is true ^ Not quite as fast though. We use them for reporting battery levels and other info instead.
@ethan_matlack How did you make the code colored?
@7447C Twisted Wire When you use the code button in the forums, it automatically does that. Sort of like how programs like Notepad++ automatically color code based on the programming language.
For the LCD you can use a code like the following:
#pragma config(Motor, port2, driveL, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, driveR, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma platform(VEX)
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(15)
#pragma userControlDuration(105)
#include "Vex_Competition_Includes.c" //Main competition background code...do not modify!
const short leftButton = 1;
const short centerButton = 2;
const short rightButton = 4;
static int count = 0; // declare count variable to keep track of our choice
//////////////////////
// Random Variables //
//////////////////////
//Wait for Press
void waitForPress()
{
while(nLCDButtons == 0){}
wait1Msec(5);
}
//Wait for Release
void waitForRelease()
{
while(nLCDButtons != 0){}
wait1Msec(5);
}
void WaitForPressAndRelease (int value = -1) {
waitForPress();
if(nLCDButtons == leftButton) {
waitForRelease();
if (value > 0) {
count = value;
}
else {
count--;
}
}
else if(nLCDButtons == rightButton) {
waitForRelease();
if (value == 0) {
count = 0;
}
else {
count++;
}
}
}
//////////////////////////////
// Pre-Autonomous Functions //
//////////////////////////////
void pre_auton()
{
bStopTasksBetweenModes = true;
SensorType[in8] = sensorNone;
wait10Msec(100);
SensorType[in8] = sensorGyro;
wait10Msec(100);
bLCDBacklight = true; // Turn on LCD Backlight
// check if the robot is disabled or enabled
if (nVexRCReceiveState & vrDisabled) {
// Disabled
}
else {
// Enabled
return; // skip LCD selection
}
// Display the battery level
string batteryString;
sprintf(batteryString, "M: %1.2f B: %1.2f", (float)nImmediateBatteryLevel/1000.0, (float)BackupBatteryLevel/1000.0);
displayLCDCenteredString(0, batteryString);
// Code Chooser
while(nLCDButtons != centerButton) {
switch(count){
case 0:
displayLCDCenteredString(1, "< No Auto. >");
WaitForPressAndRelease(6); // go forward to 4 if left is pressed
break;
case 1:
displayLCDCenteredString(1, "< Right Stars >");
WaitForPressAndRelease();
break;
case 2:
displayLCDCenteredString(1, "< Left Stars >");
WaitForPressAndRelease();
break;
case 3:
displayLCDCenteredString(1, "< Cube+Stars R.>");
WaitForPressAndRelease();
break;
case 4:
displayLCDCenteredString(1, "< Cube+Stars L.>");
WaitForPressAndRelease();
break;
case 5:
displayLCDCenteredString(1, "< Pro. Skills >");
WaitForPressAndRelease();
break;
case 6:
displayLCDCenteredString(1, "< Test >");
WaitForPressAndRelease(0); // go back to zero if right is pressed
break;
}
}
}
//////////////////////
// Autonomous Tasks //
//////////////////////
int clawHalfOpen = 700;
int clawClosed = 900;
int clawOpen = 500;
void justStarsAuto (bool isRight = true)
{
}
void cubeAndStarsAuto (bool isRight = true)
{
}
void programmingSkills ()
{
}
void Test ()
{
}
//////////////////
// LCD chooser //
//////////////////
task autonomous()
{
//SensorValue[clawEncoder] = 0;
bLCDBacklight = true; // Turn on LCD Backlight
displayLCDCenteredString(0, "Autonomous");
switch(count){
case 0:
// No Autonomous
displayLCDCenteredString(1, "No Autonomous");
break;
case 1:
displayLCDCenteredString(1, "Right Stars");
justStarsAuto(true);
break;
case 2:
displayLCDCenteredString(1, "Left Stars");
justStarsAuto(false);
break;
case 3:
displayLCDCenteredString(1, "Cube + Stars R.");
cubeAndStarsAuto(true);
break;
case 4:
displayLCDCenteredString(1, "Cube + Stars L.");
cubeAndStarsAuto(false);
break;
case 5:
displayLCDCenteredString(1, "Pro. Skills");
programmingSkills();
break;
case 6:
// test
displayLCDCenteredString(1, "Test");
Test();
break;
}
}
/////////////////////////
// Driver Control Task //
/////////////////////////
task usercontrol()
{
bLCDBacklight = true; // turn on LCD backlight
startTask(pidControllerCLAW);
while (true) // driver control loop
{
}
}