This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
haas:fall2020:common:projects:led1 [2021/09/05 13:49] – [Program] wedge | haas:fall2020:common:projects:led1 [2021/09/05 13:57] – [Program] wedge | ||
---|---|---|---|
Line 207: | Line 207: | ||
If " | If " | ||
- | <code | + | <code> |
0 0 0 0 | 0 0 0 0 | ||
0 0 0 1 | 0 0 0 1 | ||
Line 223: | Line 223: | ||
1 1 0 1 | 1 1 0 1 | ||
1 1 1 0 | 1 1 1 0 | ||
- | 1 1 1 1 < | + | 1 1 1 1 < |
0 0 0 0 < | 0 0 0 0 < | ||
0 0 0 1 | 0 0 0 1 | ||
Line 232: | Line 232: | ||
The program files provided for this project are, while not complete, a good base to start from. Be sure to ASK QUESTIONS, and do so EARLY enough so that you aren't in a mad dash to make the deadline. | The program files provided for this project are, while not complete, a good base to start from. Be sure to ASK QUESTIONS, and do so EARLY enough so that you aren't in a mad dash to make the deadline. | ||
+ | =====Bitwise logic===== | ||
+ | Since the off/on state of each LED is essentially binary in nature (or one bit of an overall sequence), why not utilize the powerful bitwise tools available to us in C? | ||
+ | |||
+ | ====bitwise-AND==== | ||
+ | C provides a bitwise AND operator, the **< | ||
+ | |||
+ | <code c> | ||
+ | char value = 5; // 00000101 in binary | ||
+ | value = value & 6; // | ||
+ | // & 00000110 | ||
+ | // | ||
+ | // | ||
+ | </ | ||
+ | |||
+ | Remember the truth table for the AND: | ||
+ | |||
+ | < | ||
+ | ( AND ) | ||
+ | A B | X | ||
+ | ====+=== | ||
+ | F F | F | ||
+ | F T | F | ||
+ | T F | F | ||
+ | T T | T | ||
+ | </ | ||
+ | |||
+ | Think of how this property could be used in combination with other concepts we've learned about in C to solve the problem at hand. | ||
+ | |||
+ | ====bitwise-iOR==== | ||
+ | C provides a bitwise inclusive OR operator, the **< | ||
+ | |||
+ | <code c> | ||
+ | char value = 5; // 00000101 in binary | ||
+ | value = value | 6; // | ||
+ | // & 00000110 | ||
+ | // | ||
+ | // | ||
+ | </ | ||
+ | |||
+ | Remember the truth table for the iOR: | ||
+ | |||
+ | < | ||
+ | ( iOR ) | ||
+ | A B | X | ||
+ | ====+=== | ||
+ | F F | F | ||
+ | F T | T | ||
+ | T F | T | ||
+ | T T | T | ||
+ | </ | ||
+ | |||
+ | Think of how this property could be used in combination with other concepts we've learned about in C to solve the problem at hand. | ||
+ | |||
+ | ====bitwise-xOR==== | ||
+ | C provides a bitwise exclusive OR operator, the **< | ||
+ | |||
+ | <code c> | ||
+ | char value = 5; // 00000101 in binary | ||
+ | value = value ^ 6; // | ||
+ | // & 00000110 | ||
+ | // | ||
+ | // | ||
+ | </ | ||
+ | |||
+ | Remember the truth table for the xOR: | ||
+ | |||
+ | < | ||
+ | ( xOR ) | ||
+ | A B | X | ||
+ | ====+=== | ||
+ | F F | F | ||
+ | F T | T | ||
+ | T F | T | ||
+ | T T | F | ||
+ | </ | ||
+ | |||
+ | Think of how this property could be used in combination with other concepts we've learned about in C to solve the problem at hand. | ||
====Grabbing project resources (on lab46)==== | ====Grabbing project resources (on lab46)==== | ||
I have prepared a **grabit** for resources related to this project. To obtain: | I have prepared a **grabit** for resources related to this project. To obtain: |