Skip to main content
added 21 characters in body
Source Link
jfpoilpret
  • 9.2k
  • 7
  • 38
  • 54

First of all, fix the following part of your code:

if (Qout[i]){pinState= 1;}//Checks the array for the value and if it is true sets the pinstate to 1, HIGH
else{pinState= 1;}//If it equals false set it to 0, LOW

into:

if (Qout[i])
{
    //Checks the array for the value and if it is true sets the pinstate to 1, HIGH
    pinState = 1;
}
else
{
    //If it equals false set it to 0, LOW
    pinState = 0;
}

Of course in, if you always set pinState to 0, it won't work as you expect :-)

Note that you should rather use HIGH and LOW constants (more readable) instead of 11 and 00.

Finally, you could make the code much simpler this way:

pinState = (Qout[i] ? HIGH : LOW);

First of all, fix the following part of your code:

if (Qout[i]){pinState= 1;}//Checks the array for the value and if it is true sets the pinstate to 1, HIGH
else{pinState= 1;}//If it equals false set it to 0, LOW

into:

if (Qout[i])
{
    //Checks the array for the value and if it is true sets the pinstate to 1, HIGH
    pinState = 1;
}
else
{
    //If it equals false set it to 0, LOW
    pinState = 0;
}

Of course in you always set pinState to 0, it won't work as you expect :-)

Note that you should rather use HIGH and LOW constants instead of 1 and 0.

Finally, you could make the code much simpler this way:

pinState = (Qout[i] ? HIGH : LOW);

First of all, fix the following part of your code:

if (Qout[i]){pinState= 1;}//Checks the array for the value and if it is true sets the pinstate to 1, HIGH
else{pinState= 1;}//If it equals false set it to 0, LOW

into:

if (Qout[i])
{
    //Checks the array for the value and if it is true sets the pinstate to 1, HIGH
    pinState = 1;
}
else
{
    //If it equals false set it to 0, LOW
    pinState = 0;
}

Of course, if you always set pinState to 0, it won't work as you expect :-)

Note that you should rather use HIGH and LOW constants (more readable) instead of 1 and 0.

Finally, you could make the code much simpler this way:

pinState = (Qout[i] ? HIGH : LOW);
Source Link
jfpoilpret
  • 9.2k
  • 7
  • 38
  • 54

First of all, fix the following part of your code:

if (Qout[i]){pinState= 1;}//Checks the array for the value and if it is true sets the pinstate to 1, HIGH
else{pinState= 1;}//If it equals false set it to 0, LOW

into:

if (Qout[i])
{
    //Checks the array for the value and if it is true sets the pinstate to 1, HIGH
    pinState = 1;
}
else
{
    //If it equals false set it to 0, LOW
    pinState = 0;
}

Of course in you always set pinState to 0, it won't work as you expect :-)

Note that you should rather use HIGH and LOW constants instead of 1 and 0.

Finally, you could make the code much simpler this way:

pinState = (Qout[i] ? HIGH : LOW);