I was trying to use this library to hack an optical mouse with my arduino:
Can someone explain to me this type of code which is suppose to Write the address of the register we want to read:
pinMode (_sdioPin, OUTPUT);
for (; i>=0; i–)
digitalWrite (_sclkPin, LOW);
digitalWrite (_sdioPin, address & (1 << i));
digitalWrite (_sclkPin, HIGH);
this code is part of the file optimouse.cpp in the library
What I don’t get in this code is that I thought digitalWrite could have only 1 or 0 as a second parameter.
From my understandign the symbol << mean a bit shift, so in this example if i = 2, 1<<2 = 100.
But how come this code can set a register?