Pixy2 PWM and for

Hello
I want to drive pwm with Pixy2, but the for loop is crashing the system

  int16_t res;
  int32_t error;

  char buf[96];
  res = pixy.line.getMainFeatures();
  if (res <= 0) {

  analogWrite(pwmoutr,0);
  analogWrite(pwmoutl,0);
  
  } else if (pixy.line.vectors->m_x1-sensL >= X_CENTER ) {

    for (int i = 0 , i < 255, i++){
    analogWrite(pwmoutl,i);
    }
  
  myGLCD.setFont(Arial_round_16x24);
  myGLCD.setColor(255, 0, 0);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.print("<<<LEFT", 5, 70);

  } else if (pixy.line.vectors->m_x1+sensR <= X_CENTER) {

    for (int i = 0 , i < 255, i++){
    analogWrite(pwmoutr,i);
    }

  myGLCD.setFont(Arial_round_16x24);
  myGLCD.setColor(255, 0, 0);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.print("RIGHT>>>", 345,70);

  } 

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.