Skip to content

Commit 3a396de

Browse files
authored
Merge pull request #658 from c7h/patch-1
improve code example Indentation
2 parents 0d89375 + fb32fc2 commit 3a396de

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

content/learn/03.programming/09.bit-mask/bit-mask.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ The AND (&) operator will result in a 1 at each bit position where both input va
1313
For example:
1414

1515
```arduino
16-
x: 10001101
17-
16+
x: 10001101
17+
1818
y: 01010111
1919
2020
x & y: 00000101
@@ -24,7 +24,7 @@ The OR (|) operator (also known as Inclusive Or) will result in a 1 at each bit
2424
For example:
2525

2626
```arduino
27-
x: 10001101
27+
x: 10001101
2828
2929
y: 01010111
3030
@@ -35,7 +35,7 @@ The Left Shift (<<) operator will shift a value to the left the specified number
3535
For example:
3636

3737
```arduino
38-
y = 1010
38+
y = 1010
3939
4040
x = y << 1
4141
@@ -48,7 +48,7 @@ The Right Shift (>>) operator works identically to left shift except that it shi
4848
For example:
4949

5050
```arduino
51-
y = 1010
51+
y = 1010
5252
5353
x = y >> 1
5454
@@ -97,7 +97,7 @@ void loop()
9797
Here we use a FOR loop to iterate through a bit mask value, shifting the value one position left each time through the loop. In this example we use the <<= operator which is exactly like the << operator except that it compacts the statement
9898

9999
```arduino
100-
00000001
100+
00000001
101101
& 10101010
102102
103103
________
@@ -109,12 +109,12 @@ And our output pin gets set to 0.
109109
Second time through the loop the mask = 00000010, so our operation looks like:
110110

111111
```arduino
112-
00000010
112+
00000010
113113
& 10101010
114114
115115
________
116116
117117
00000010
118118
```
119119

120-
And our output pin gets set to 1. The loop will continue to iterate through each bit in the mask until the 1 gets shifted left off the end of the 8 bits and our mask =0. Then all 8 bits have been sent and our loop exits.
120+
And our output pin gets set to 1. The loop will continue to iterate through each bit in the mask until the 1 gets shifted left off the end of the 8 bits and our mask =0. Then all 8 bits have been sent and our loop exits.

0 commit comments

Comments
 (0)