error message "void not being ignored as it should be"

void loop()
{

for(int k = 1,j=22;j<38, k < 5;k++,j++){
int inc1[] = {1, 0, 0, 0};
int state = digitalWrite(j,inc1[k]);
  Serial.println("");
  Serial.print(inc1[k]);
  Serial.print(analogRead(k-1));
  Serial.print(k);
  

}
}

please state the nature of your emergency ...

  • use CTRL-T in the IDE for readability
  • post code according guidelines on top of every section

thanks for using code tags ;)

int state = digitalWrite(j,inc1[k]);

void not being ignored as it should be

digitalWrite() is a void function, you cannot assign it’s return value to anything as there isn’t one.

;j<38, k < 5;

Is that even valid code? It compiles but I don’t know what it does.


Rob

It is valid, but pointless in this instance. The “,” operator evaluates both sides for side-effects and returns the value of the right-hand side. In this case throwing out the result of j<38.

it would have made sense if it said

 for(int k = 1, j = 22;   (j < 38) &&  (k < 5); k++, j++ ){