Hi
This code makes me insane:
void loop() // run over and over again
{
for(x=200; x>0; x--)
{
udData(sqA, La0);
udData(sqA, La1);
}
for(x=200; x>0; x--)
{
udData(sqB, La1);
udData(sqB, La2);
}
for(x=200; x>0; x--)
{
udData(sqC, La2);
udData(sqC, La3);
}
}
void udData (unsigned int data, int layer)
{
if(data>255)
{
shiftOut(dataPin, clockPin, LSBFIRST, data);
shiftOut(dataPin, clockPin, LSBFIRST, (data >> 8));
}
else
{
shiftOut(dataPin, clockPin, LSBFIRST, 0);
shiftOut(dataPin, clockPin, LSBFIRST, data);
}
digitalWrite(latchPin, HIGH);
digitalWrite(layer, LOW);
delay(1);
digitalWrite(layer, HIGH);
}
When finished with the first for loop shifting out 'sqA' it doesn't throw away the value of 'sqA'.
Instead of sending the new value of 'sqB' to udData() it still uses 'sqA' for output.
This gives me 3 for-loops with the same data-value but different 'layer'-value.
Anyone knows a solution?
hope to get an answer.