Odd counter problem..
i have 5 leds in circle, when count through them 1 @ time counter clockwise you'd imagine when try & go clockwise nothing happens?
here snippet of code amended arduino-shift register example...
so missing here?
i thought read out dataarray backwards?!?!
thanks
nic
here snippet of code amended arduino-shift register example...
quote
dataarray[0] = 0x10;
dataarray[1] = 0x08;
dataarray[2] = 0x04;
dataarray[3] = 0x02;
dataarray[4] = 0x01;
quote
// counter clockwise
(int j = 0; j < 5; j++) {
//load light sequence want array
data = dataarray[j];
//ground latchpin , hold low long transmitting
digitalwrite(latchpin, 0);
//move 'em out
shiftout(datapin, clockpin, data);
//return latch pin high signal chip it
//no longer needs listen information
digitalwrite(latchpin, 1);
delay(300);
}
// clockwise
(int k = 4; k < 0; k--) {
//load light sequence want array
data = dataarray[k];
//ground latchpin , hold low long transmitting
digitalwrite(latchpin, 0);
//move 'em out
shiftout(datapin, clockpin, data);
//return latch pin high signal chip it
//no longer needs listen information
digitalwrite(latchpin, 1);
delay(300);
}
so missing here?
i thought read out dataarray backwards?!?!
thanks
nic
the "k < 0" means run for-loop while k less zero. in other words, loop not executed.
code: [select]
// (int k = 4; k < 0; k--) // bad
for (int k = 4; k>=0; k--) // good
Arduino Forum > Using Arduino > LEDs and Multiplexing > Odd counter problem..
arduino
Comments
Post a Comment