I'm having little trouble with using binary and bitwise operator to make led work. I"m using inputs 2,3,4,5 and trying to turn it on by following mechanism.
2(on)
2,3(on)
2,3,4(on)
2,3,4,5(on)
2,3,4(on)
2,3 (on)
2 (on)
Below is the general skeleton code I've created using bitwise operator. But how do I apply this to digitalWrite??? I need help.
int pattern=1, shift;
if (index<4) shift = index;
else shift = 6-index;
Iterate through pattern using the value of the iterator to do a bit.read on each bit in turn. If the bit is on/off set/reset the corresponding digital output. If the digital outputs aren't contiguous you can set up an array which holds the output pin numbers and retrieve them with the iterator as an index.