User Tools

Site Tools


haas:fall2020:common:projects:led1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
haas:fall2020:common:projects:led1 [2021/09/05 09:49] – [Program] wedgehaas:fall2020:common:projects:led1 [2021/09/05 09:58] – [On your pi] wedge
Line 223: Line 223:
 1 1 0 1 1 1 0 1
 1 1 1 0 1 1 1 0
-1 1 1 1   <-- 15+1 1 1 1   <-- 15, the maximum value to display
 0 0 0 0   <-- 0, we "roll over" and start again 0 0 0 0   <-- 0, we "roll over" and start again
 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 **<nowiki>&</nowiki>** symbol, which can be used in equations to perform bitwise-AND operations:
 +
 +<code c>
 +char value  = 5;         // 00000101 in binary
 +value       = value & 6; //   00000101
 +                         // & 00000110
 +                         //   ========
 +                         //   00000100
 +</code>
 +
 +Remember the truth table for the AND:
 +
 +<code>
 +( AND )
 +A B | X
 +====+===
 +F F | F
 +F T | F
 +T F | F
 +T T | T
 +</code>
 +
 +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 **<nowiki>|</nowiki>** symbol, which can be used in equations to perform bitwise-iOR operations:
 +
 +<code c>
 +char value  = 5;         // 00000101 in binary
 +value       = value | 6; //   00000101
 +                         // & 00000110
 +                         //   ========
 +                         //   00000111
 +</code>
 +
 +Remember the truth table for the iOR:
 +
 +<code>
 +( iOR )
 +A B | X
 +====+===
 +F F | F
 +F T | T
 +T F | T
 +T T | T
 +</code>
 +
 +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 **<nowiki>^</nowiki>** symbol, which can be used in equations to perform bitwise-xOR operations:
 +
 +<code c>
 +char value  = 5;         // 00000101 in binary
 +value       = value ^ 6; //   00000101
 +                         // & 00000110
 +                         //   ========
 +                         //   00000011
 +</code>
 +
 +Remember the truth table for the xOR:
 +
 +<code>
 +( xOR )
 +A B | X
 +====+===
 +F F | F
 +F T | T
 +T F | T
 +T T | F
 +</code>
 +
 +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:
Line 256: Line 333:
  
 ====On your pi==== ====On your pi====
-Study and run this program on your pi in conjunction with testing and verifying operation of your properly hooked up electronics circuit. When done, submit it on lab46.+Implement the needed program on your pi in conjunction with testing and verifying operation of your properly hooked-up electronics circuit. When done, submit it on lab46.
  
 To utilize the needed functionality for this project, you will need to ensure you have the following packages installed: To utilize the needed functionality for this project, you will need to ensure you have the following packages installed:
haas/fall2020/common/projects/led1.txt · Last modified: 2021/09/05 10:01 by 127.0.0.1