Program garbage

I’m trying to get my program to detect a color with a vision sensor and move a motor, and if such color isn’t present it should move the motors the other direction. The issue is that it only take a snapshot when the program starts. I instead want it to continue searching for this one color and then proceed to move the motor when it detects it. Does anyone know what I can do to fix it?ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

It looks like you forgot to put it in while loop.

3 Likes

Actually, it looks like there is no while loop present at all. The problem with this is you are telling your program to take a picture, spin the motors and then do nothing more. I’m also a bit surprised the code works at all since you are running hardware before vexcodeInit();.

I would suggest you take all your code and place it in a while loop in a way kind of like

using namespace vex;
  int main() {
  vexcodeInit();
  while(true)
  {
    // take the snapshot here, no need for the if(1)
    if(/*your camera behaviors*/)
    {
 
    } // if
  } // while
} // main

As a little additional point, watch how you are tabbing. Some of the parts of your code are tabbed over in strange ways. It becomes confusing what brackets are inside of others. Give this a try and see what the results are.

4 Likes