Hi,
I'm making an Led cube, and rather than just copy some code, i want to understand it and write a program for myself, i understand all the code except for one line, care to help?
the code is here:
the specific line is this : "digitalWrite( LEDPin[ledpin++], PatternBuf[patbufidx] & (1 << ledcol) );"
now i know this code works cuz i have loaded it up and tried it before.
so my questions:
- why is it LEDPin[ledpin++]? wouldnt that skip a port?
- In "PatternBuf[patbudfidx] & (1 << ledcol) );" patternBuf[patbudfidx] selects the byte from the array that corresponds with the row that is in question (i think), then uses an and operator (read the page on it) with the integar value of ledcol shifted to the left 1. I thought bitshifts applied to binary? and why does it do this? (my guess is that it selects the column that it should be out of the byte representing the row) if i am correct, how does this work?
- can you use a byte to set the state? wouldnt it return 1 or 0? can u replace HIGH and LOW with 1 and 0? i havent seen eveidence of this being true anywhere else.
Thanks for the help!