My brain still wont Execute code, at all

I dont want to seem picky or annoying anything like that but my brain still wont execute code and i need answers as to the upcoming event where we will need to program the robot.

When you would go to vexcode and try to run any bit of code, i get a blank screen that appears and does nothing where the code should appear.

I was asked to give an debug, but this is happening with every bit of code that happens.

Im hoping that their is a solution to this, as the brain is brand new sponsor from dell, and their isnt something defective with this device as well.
Currently im running the most up to date version of vexcode, the brain is the most up to dater firmware as well.

currently we are running a dell laptop with windows 7 enterprise with a i7 3740QM and nvida quadro k2000m gpu.

@jpearman

4 Likes

When you say blank screen, do you mean on your computer or on the V5 Brain? If you mean the brain, it is normal for the screen to be black when you run a program, unless you program it to display something.

2 Likes

Have you tried using a different laptop or USB cable. V5 Brains are very picky on the type of micro USB cables it accepts.

With the robot and computer in front of you, along with an extra usb cable and charged battery if you have them, call Vex technical support and they will walk you through troubleshooting your issue.

6 Likes

to solve this problem, we had to copy/paste code that we got from another team. If you need, I can send you a sample

2 Likes

the brain itself just goes blank, not completely with some information above saying its executing code and saying how long its been doing it for.

It was tested on two work laptop, an hp with amd a6 pro 7050b, and a dell laptop with i7 3740QM. They where all usb 2.0 ports as well

Please send a sample

That is what is supposed to happen. Unless you program the brain to display some kind of information on the screen, then most of the screen will be blank besides the top banner that displays some info. This means that your code is actually running, but if it is not doing what you want it to then there is some other error in your code. If you attach your project I would be happy to look through it and see if I can find your problem.

3 Likes

yes. here you go!

/*----------------------------------------------------------------------------*/
/* */
/* Module: main.cpp */
/* Author: VEX */
/* Created: Thu Sep 26 2019 */
/* Description: Competition Template */
/* Button Code: https://www.vexforum.com/t/walshbots-autonomous-feature-selector/51534 */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name]               [Type]        [Port(s)]
// Controller1          controller                    
// FrontLeft            motor         1               
// BackLeft             motor         2               
// Arm                  motor         3               
// LeftIntake           motor         4               
// RightIntake          motor         7               
// Lift                 motor         8               
// FrontRight           motor         9               
// BackRight            motor         10              
// ---- END VEXCODE CONFIGURED DEVICES ----


#include "vex.h"

using namespace vex;

// A global instance of competition
competition Competition;
int autonomousSelection = -1;

typedef struct _button {
int xpos;
int ypos;
int width;
int height;
bool state;
vex::color offColor;
vex::color onColor;
const char *label;
} button;

button buttons[] = {
{ 30, 30, 60, 60, false, 0xE00000, 0x0000E0, "Color" },
{ 150, 30, 60, 60, false, 0x303030, 0xD0D0D0, "far" },
{ 270, 30, 60, 60, false, 0x303030, 0xF700FF, "Tower" },
{ 390, 30, 60, 60, false, 0x303030, 0xDDDD00, "3" },
{ 30, 150, 60, 60, false, 0x404040, 0xC0C0C0, "4" },
{ 150, 150, 60, 60, false, 0x404040, 0xC0C0C0, "5" },
{ 270, 150, 60, 60, false, 0x404040, 0xC0C0C0, "6" },
{ 390, 150, 60, 60, false, 0x404040, 0xC0C0C0, "7" }
};

void displayButtonControls( int index, bool pressed );

/*-----------------------------------------------------------------------------*/
/** @brief Check if touch is inside button */
/*-----------------------------------------------------------------------------*/
int
findButton( int16_t xpos, int16_t ypos ) {
 int nButtons = sizeof(buttons) / sizeof(button);

 for( int index=0;index < nButtons;index++) {
 button *pButton = &buttons[ index ];
 if( xpos < pButton->xpos || xpos > (pButton->xpos + pButton->width) )
 continue;

 if( ypos < pButton->ypos || ypos > (pButton->ypos + pButton->height) )
 continue;

 return(index);
 }
 return (-1);
}

/*-----------------------------------------------------------------------------*/
/** @brief Init button states */
/*-----------------------------------------------------------------------------*/
void
initButtons() {
 int nButtons = sizeof(buttons) / sizeof(button);

 for( int index=0;index < nButtons;index++) {
 buttons[index].state = false;
 }
}

/*-----------------------------------------------------------------------------*/
/** @brief Screen has been touched */
/*-----------------------------------------------------------------------------*/
void
userTouchCallbackPressed() {
 int index;
 int xpos = Brain.Screen.xPosition();
 int ypos = Brain.Screen.yPosition();

 if( (index = findButton( xpos, ypos )) >= 0 ) {
 displayButtonControls( index, true );
 }

}

/*-----------------------------------------------------------------------------*/
/** @brief Screen has been (un)touched */
/*-----------------------------------------------------------------------------*/
void
userTouchCallbackReleased() {
 int index;
 int xpos = Brain.Screen.xPosition();
 int ypos = Brain.Screen.yPosition();

 if( (index = findButton( xpos, ypos )) >= 0 ) {
 // clear all buttons to false, ie. unselected
 // initButtons(); 

 // now set this one as true
 if( buttons[index].state == true) {
 buttons[index].state = false; }
 else {
 buttons[index].state = true;}

 // save as auton selection
 autonomousSelection = index;

 displayButtonControls( index, false );
 }
}

/*-----------------------------------------------------------------------------*/
/** @brief Draw all buttons */
/*-----------------------------------------------------------------------------*/
void
displayButtonControls( int index, bool pressed ) {
 vex::color c;
 Brain.Screen.setPenColor( vex::color(0xe0e0e0) );

 for(int i=0;i<sizeof(buttons)/sizeof(button);i++) {

 if( buttons[i].state )
 c = buttons[i].onColor;
 else
 c = buttons[i].offColor;

 Brain.Screen.setFillColor( c );

 // button fill
 if( i == index && pressed == true ) {
 Brain.Screen.drawRectangle( buttons[i].xpos, buttons[i].ypos, buttons[i].width, buttons[i].height, c );
 }
 else
 Brain.Screen.drawRectangle( buttons[i].xpos, buttons[i].ypos, buttons[i].width, buttons[i].height );

 // outline
 Brain.Screen.drawRectangle( buttons[i].xpos, buttons[i].ypos, buttons[i].width, buttons[i].height, vex::color::transparent );

// draw label
 if( buttons[i].label != NULL )
 Brain.Screen.printAt( buttons[i].xpos + 8, buttons[i].ypos + buttons[i].height - 8, buttons[i].label );
 }
}

// define your global instances of motors and other devices here

/*---------------------------------------------------------------------------*/
/* Pre-Autonomous Functions */
/* */
/* You may want to perform some actions before the competition starts. */
/* Do them in the following function. You must return from this function */
/* or the autonomous and usercontrol tasks will not be started. This */
/* function is only called once after the V5 has been powered on and */
/* not every time that the robot is disabled. */
/*---------------------------------------------------------------------------*/

void pre_auton(void) {
 // Initializing Robot Configuration. DO NOT REMOVE!
 vexcodeInit();

 // All activities that occur before the competition starts
 // Example: clearing encoders, setting servo positions, ...
}


/*---------------------------------------------------------------------------*/
/* */
/* Autonomous Task */
/* */
/* This task is used to control your robot during the autonomous phase of */
/* a VEX Competition. */
/* */
/* You must modify the code to add your own robot specific commands here. */
/*---------------------------------------------------------------------------*/

void autonomous(void) {}

/*---------------------------------------------------------------------------*/
/* */
/* User Control Task */
/* */
/* This task is used to control your robot during the user control phase of */
/* a VEX Competition. */
/* */
/* You must modify the code to add your own robot specific commands here. */
/*---------------------------------------------------------------------------*/

void usercontrol(void) {
 // User control code here, inside the loop

int temp = 0;


 //hi
 while (true) {
 if (Controller1.ButtonX.pressing()&&temp<1)
{
 autonomous();
  
  FrontLeft.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
  BackLeft.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
  FrontRight.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
  BackLeft.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
  LeftIntake.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
  RightIntake.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
  
  FrontLeft.stop(brakeType::coast);
  BackLeft.stop(brakeType::coast);
  FrontRight.stop(brakeType::coast);
  BackLeft.stop(brakeType::coast);
  LeftIntake.stop(brakeType::coast);
  RightIntake.stop(brakeType::coast);
}



 // FrontLeft.spin(vex::directionType::rev, Controller1.Axis1.position() + Controller1.Axis3.position(), vex::velocityUnits::pct);
 // BackLeft.spin(vex::directionType::fwd, Controller1.Axis1.position() + Controller1.Axis3.position(), vex::velocityUnits::pct);
 // FrontRight.spin(vex::directionType::rev, Controller1.Axis1.position() - Controller1.Axis3.position() , vex::velocityUnits::pct);
 // BackRight.spin(vex::directionType::fwd, Controller1.Axis1.position() - Controller1.Axis3.position() , vex::velocityUnits::pct); 
 // leftValue=Controller1.Axis3.value() + Controller1.Axis1.value();
 // rightValue=Controller1.Axis3.value() - Controller1.Axis1.value();
 
 FrontLeft.spin(vex::directionType::fwd, Controller1.Axis3.position(), vex::velocityUnits::pct);
 BackLeft.spin(vex::directionType::fwd, Controller1.Axis3.position(), vex::velocityUnits::pct);
 FrontRight.spin(vex::directionType::fwd, Controller1.Axis2.position() , vex::velocityUnits::pct);
 BackRight.spin(vex::directionType::fwd, Controller1.Axis2.position(), vex::velocityUnits::pct);
 //Tank drive ^^

 

 if(Controller1.ButtonR2.pressing()) //intake sucks in
 {
 LeftIntake.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
 RightIntake.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
 }
 else if(Controller1.ButtonR1.pressing()) //intake blows out
 {
 LeftIntake.spin(vex::directionType::fwd, -100, vex::velocityUnits::pct);
 RightIntake.spin(vex::directionType::fwd, -100, vex::velocityUnits::pct);
 }
 else 
 {
 LeftIntake.stop(brakeType::coast);
 RightIntake.stop(brakeType::coast);
 } 
 if(Controller1.ButtonA.pressing())  //Spinner Slowly Sucks
 {
   LeftIntake.spin(vex::directionType::fwd, 80, vex::velocityUnits::pct);
   RightIntake.spin(vex::directionType::fwd, 80, vex::velocityUnits::pct);
 }
 else if(Controller1.ButtonY.pressing()) //Spinner Slowly Blows
 {
   RightIntake.spin(vex::directionType::fwd, -80, vex::velocityUnits::pct);
   LeftIntake.spin(vex::directionType::fwd, -80, vex::velocityUnits::pct);
 }
 if(Controller1.ButtonL2.pressing()) //Lift up
 {
 Lift.spin(vex::directionType::fwd, 70, vex::velocityUnits::pct);
 
 }
 else if(Controller1.ButtonL1.pressing()) //Lift down
 {
 Lift.spin(vex::directionType::fwd, -70, vex::velocityUnits::pct);
 
 }
 else 
 {
 Lift.stop(brakeType::coast); 
 } 

 
 if(Controller1.ButtonUp.pressing()) //tray out
 {
 Arm.spin(vex::directionType::fwd, 40, vex::velocityUnits::pct);
 
 }
 else if(Controller1.ButtonDown.pressing())//tray in
 {
 Arm.spin(vex::directionType::fwd, -40, vex::velocityUnits::pct);
 
 }
 else 
 {
 Arm.stop(brakeType::brake); 
 } 
 

 wait(20, msec); // Sleep the task for a short amount of time to
 // prevent wasted resources.
 }
}

//
// Main will set up the competition functions and callbacks.
//
int main() {
 // Set up callbacks for autonomous and driver control periods.
 Competition.autonomous(autonomous);
 Competition.drivercontrol(usercontrol);

 // Brain.Screen.print("ANDY JOW,ANDY JOW,ANDY JOW,ANDY JOW,ANDY JOW,ANDY JOW,ANDY JOW,ANDY JOW,ANDY JOW,ANDY JOW,ANDY JOW");
 //Brain.Screen.printAt(50,150, "Tray:%f", Arm.rotation(rotationUnits::deg));

 // Run the pre-autonomous function.
 pre_auton();
 
 Brain.Screen.pressed( userTouchCallbackPressed );
 Brain.Screen.released( userTouchCallbackReleased );

 // make nice background
 Brain.Screen.setFillColor( vex::color(0x404040) );
 Brain.Screen.setPenColor( vex::color(0x404040) );
 Brain.Screen.drawRectangle( 0, 0, 480, 120 );
 Brain.Screen.setFillColor( vex::color(0x808080) );
 Brain.Screen.setPenColor( vex::color(0x808080) );
 Brain.Screen.drawRectangle( 0, 120, 480, 120 );

 // initial display
 displayButtonControls( 0, false );

 while(1) {
 // Allow other tasks to run
 if( !Competition.isEnabled() )
 Brain.Screen.setFont(fontType::mono40);
 Brain.Screen.setFillColor( vex::color(0xFFFFFF) );

 Brain.Screen.setPenColor( vex::color(0xc11f27));
 Brain.Screen.printAt( 0, 135, " THISTEAMGODMODE " );
 this_thread::sleep_for(10);
 }

 // Prevent main from exiting with an infinite loop.
 while (true) {
 wait(100, msec);
 }
}

Unfortunately I do not have time today to test this with a V5, but I can give you some tips for debugging it. Has your program never worked, or was it working until you made a change and then stopped working? If it stopped working after you made a change, I would recommend commenting out the change you made, then test if it works. If so, then slowly uncomment out your code until you find the exact part that is causing it to not work. However, if it has never worked at all, then I would recommend commenting it all out except for something basic like tank control. Once you get something basic to work correctly, then you can slowly build up your program from there until you find the problem.

Bob1
You should post your code, use the export function and upload to this thread.

There is no way for anyone to effectively help you without viewing your code.

Have you tried to load an example program to the v5? What results do you see with a example provided with V5 text?
what version of vexcode are you using?

2 Likes

Oh my bad, when @24yshukla posted their code I didn’t look at the username and I though it was @bob1 posting his code

I did the same, then went back and checked :slight_smile: