How to use Vision Sensor to see objects

I recently started working with the Vision Sensor. My class and I have not yet used the Vision Sensor, and are trying to figure out how to use it.

The program I have (at bottom) is based on a document at this link.
It is supposed to just take a Snapshot and then report whether or not it sees the red object. However, when I run the program, the robot never sees the object, even when the window to configure the sensor shows that it can.
Is there a problem in my program which causes the robot to fail to see or to recognize the red object? If there is, what would I need to do to fix it?

void redCallBack(){
    Brain.Screen.print("Red Object Found");
    Brain.Screen.print("No Red Object Found");

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!


Don’t know how much help this will be but this is the code I used in Change Up to identify a blue ball with the vision sensor:

 void searchForBlue() {
 while(1) {
 // get latest objects 
int numberObjects = Vision12.takeSnapshot(Vision12__BLUEBOX);Vision12.takeSnapshot( 
Vision12_BLUEBOX2 );Vision12.takeSnapshot( Vision12_BLUEBOX3 );
if( numberObjects > 0 ) {
  // make a copy
  vex::vision::object obj = Vision12.objects[0];
  wait(0, timeUnits::sec);
  backflap.spinFor(directionType::fwd, 0.7, rotationUnits::rev, 100, velocityUnits::pct);
  FR.spinFor(directionType::rev, 0.6, timeUnits::sec, 100, velocityUnits::pct);
else if(Controller1.ButtonR1.pressing()){
backflap.spin(directionType::rev, 100, velocityUnits::pct);
FR.spin(directionType::rev, 100, velocityUnits::pct);

else if(Controller1.ButtonL1.pressing()){
backflap.spin(directionType::fwd, 100, velocityUnits::pct);
FR.spin(directionType::fwd, 100, velocityUnits::pct);

else{backflap.stop(brakeType::coast), FR.stop(brakeType::coast);}


Just for context, the bluebox color signatures I was checking were different brightness levels of blue, and the else if’s was the driver control code if there wasn’t it a blue ball in the intake

1 Like

is there a blocky version of this I am using robot mesh studio blockly Vex V5 so my teammates and I can understand

basically you need to tell the vision sensor what is red with the vision utility. more of it here:

then you can use that code

1 Like