Pages: [1]   Go Down
Author Topic: 'if' equation always firing...  (Read 428 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 1
Posts: 33
Yes.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a piece of code...

Code:
for (int i = 0; i < 8; i++) {
     temp = (j * 8) + i;
     temp3 = ledArray[temp];
     if (temp3 >= x ); {
     Serial.print(temp3, DEC);
     Serial.println(x, DEC);
     ledOut |= bit(i);
   }   //end if
    }  //next i
I had all the functions of temp3 = blabla embedded in the if statement, and took them out just to make sure.

Now...the way it works is I'm breaking an array of 24 into chunks of 8 for evaluation then shifting out to a shift register.
It used to work with just one shift register, but as soon as I made the array bigger it no longer works:
Serial Display:
Code:
01
01
01
01
01
01
01
01
After i, before shiftout
255
Zero is not greater than or equal to one, so it should not fire the if, but it does...8 times in a row.  No matter what data gets passed to this statement it doesnt seem to work.
255 is the decimal format of the bitwise setting of all 8 bits in the byte ledArray.

**back story, the whole point of this is I'm doing 3 bit (8 step) pwm control of an array of leds through shift registers by shifting at maximum speed.  I'm THIS close to giving up on the pwm concept - once the array gets as big as I hope (hundreds of leds) pwm will be unfeasable - but at this small prototyping stage I have some cool animations for an 8 led system...blargh.

Thanks in advance!  Please tell me I'm missing something stupid.
Logged

Waterloo, Canada
Offline Offline
Full Member
***
Karma: 1
Posts: 242
Engineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Looky here...
Code:
if (temp3 >= x ); {

You have a rogue ";"
Logged

Pages: [1]   Go Up
Jump to: