system
February 8, 2009, 10:55am
1
Hi,
I am working through the LEDDriver Tutorial at http://www.arduino.cc/en/Tutorial/LEDDriver
Can anybody tell me what the '&' symbol represents? ie digitalWrite(data, dato & 01); Does this mean that 'dato & O1' will return true if dato is equal to 1?
I appreciate the help.
mem
February 8, 2009, 11:06am
2
'&' is the symbol for the bitwise and operation - you can find the symbols for all the bitwise operators in the extended reference : Arduino - Home
(dato & 01) will have a value of 1 if the least significant bit of data is 1, otherwise it will have a value of 0.
HIGH is defined as 1 so the expression:
digitalWrite(data, dato & 01);
will write a high value if dato is odd, a low value if dato is even
Another way of thinking of a number with the least significant bit of zero is to think of it as an even number.