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 [2020/09/03 13:31] – [The Circuit to Construct] wedgehaas:fall2020:common:projects:led1 [2021/09/05 09:58] – [On your pi] wedge
Line 3: Line 3:
  
 =====Objective===== =====Objective=====
-To expand upon our previous efforts, through wiring up additional LEDs and generating a "binary counting" pattern of lit LEDs on your pi.+To expand upon our previous efforts, through wiring up additional LEDs and discovering what pattern they activate in, given the provided program.
  
 We also further utilize time constraints, tying project credit to your starting on the project before the deadline (so be sure to plan accordingly!) We also further utilize time constraints, tying project credit to your starting on the project before the deadline (so be sure to plan accordingly!)
Line 106: Line 106:
  
 {{ :haas:fall2020:common:projects:breadboardlogic.png?400 |}} {{ :haas:fall2020:common:projects:breadboardlogic.png?400 |}}
 +
 +Here's a good video overview of the functionality of a breadboard:
 +
 +  * https://www.youtube.com/watch?v=6WReFkfrUIk
 ====(1) T-cobbler and data cable==== ====(1) T-cobbler and data cable====
 In your kit should be a T-shaped device (known as the "T-cobbler" with some aspect of pin names silkscreened on it, and a 40-pin ribbon cable). Colors may vary, but essentially it looks like this: In your kit should be a T-shaped device (known as the "T-cobbler" with some aspect of pin names silkscreened on it, and a 40-pin ribbon cable). Colors may vary, but essentially it looks like this:
Line 144: Line 148:
 Take note of how everything is being plugged in, and what connection on the T-cobbler is being utilized. Take note of how everything is being plugged in, and what connection on the T-cobbler is being utilized.
  
-Notice how the circuit runs from ground to resistor to LED to pin "GPIO17/Physical pin 11/Wiring Pi pin 0"+Notice how the circuit runs from ground to LED to resistor to pin "GPIO17/Physical pin 11/Wiring Pi pin 0"
  
 Please keep in mind: Please keep in mind:
Line 155: Line 159:
 <WRAP info>Before you seek to actually test your circuit, please get verification to proceed from the class channel on discord by posting a clear picture of everything. There are MANY moving parts, and especially as we have our first exposure, it is best to insert as many quality control checks as possible to ensure the greatest chances of mistakes are mitigated.</WRAP> <WRAP info>Before you seek to actually test your circuit, please get verification to proceed from the class channel on discord by posting a clear picture of everything. There are MANY moving parts, and especially as we have our first exposure, it is best to insert as many quality control checks as possible to ensure the greatest chances of mistakes are mitigated.</WRAP>
  
 +<WRAP info>It may be clarifying if you arranged your four LEDs in a row, from right to left, in order of your GPIO pins you've plugged into.</WRAP>
 ====Testing connectivity==== ====Testing connectivity====
 To verify whether everything is hooked up correctly (including the correct positioning of the LED), please try the following: To verify whether everything is hooked up correctly (including the correct positioning of the LED), please try the following:
Line 172: Line 177:
  
 <cli> <cli>
-yourpi:~/src/desig/led0$ gpio mode 0 OUT+yourpi:~/src/desig/led1$ gpio mode 0 OUT
 </cli> </cli>
  
Line 188: Line 193:
  
 <cli> <cli>
-yourpi:~/src/desig/led0$ gpio write 0 1      ## activate voltage on wiringpi pin 0 (turn on) +yourpi:~/src/desig/led1$ gpio write 0 1      ## activate voltage on wiringpi pin 0 (turn on) 
-yourpi:~/src/desig/led0$ gpio write 0 0      ## deactivate voltage on wiringpi pin 0 (turn off)+yourpi:~/src/desig/led1$ gpio write 0 0      ## deactivate voltage on wiringpi pin 0 (turn off)
 </cli> </cli>
  
Line 196: Line 201:
 If you get no activity out of the LED, try reversing it and try again. If you get no activity out of the LED, try reversing it and try again.
  
 +With an expanded set of LED circuits, be sure to test the operation of each one.
 =====Program===== =====Program=====
-It is your task to compilerunexpand uponand understand program to interface with a set of LEDs (light emitting diodes), a nice software-hardware connection, on your raspberry pi.+It is your task to write a C program that interfaces successfully with four independently connected LED circuitsarranged in some orientation to ascertain an order or positioningwhere your program will (in endless fashionor until being manually interrupted) display count (in binaryof values from 0 to 15 (then rolloveror reset).
  
-The program files provided for this project are, while not complete, minimally functional. You merely have to get it on your pi, compile it, and run it, and expand it with the appropriate circuitry hooked up to the specified places. You will want to make sure you UNDERSTAND what is going on. So be sure to ASK QUESTIONSand do so EARLY enough so that you aren't in mad dash to make the deadline.+If "1" means the LED in that position is ON, and "0" means the LED in that position is OFFthen you want to write program that performs the following progression (over and over again):
  
-In future projects you will start implementing more logic to attain further functionality.+<code> 
 +0 0 0 0 
 +0 0 0 1 
 +0 0 1 0 
 +0 0 1 1 
 +0 1 0 0 
 +0 1 0 1 
 +0 1 1 0 
 +0 1 1 1 
 +1 0 0 0 
 +1 0 0 1 
 +1 0 1 0 
 +1 0 1 1 
 +1 1 0 0 
 +1 1 0 1 
 +1 1 1 0 
 +1 1 1 1   <-- 15, the maximum value to display 
 +0 0 0 0   <-- 0, we "roll over" and start again 
 +0 0 0 1 
 +0 0 1 0 
 +... 
 +</code> 
 + 
 +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 227: 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:
Line 235: Line 341:
  
 ===Installing wiringpi=== ===Installing wiringpi===
-<WRAP info>NOTE: you should have already done this in led0; you do not need to do it again</WRAP>+<WRAP info>NOTE: you should have already installed wiringpi in order to do the led0 project; you do not need to do it again</WRAP>
  
 An exception to the usual package installation process, especially for those with a Raspberry Pi model 4B: when you install **wiringpi** the usual way, we may end up with errors when proceeding further, such as the following: An exception to the usual package installation process, especially for those with a Raspberry Pi model 4B: when you install **wiringpi** the usual way, we may end up with errors when proceeding further, such as the following:
Line 294: Line 400:
 <code> <code>
 39:led1:final tally of results (39/39) 39:led1:final tally of results (39/39)
-*:led1:post picture of unpowered layout1 to #desig and get approval [6/6] +*:led1:post picture of unpowered layout to #desig and get approval [6/6] 
-*:led1:post picture of unpowered layout2 to #desig and get approval [6/6] +*:led1:post picture to #desig by Sunday before deadline [6/6] 
-*:led1:post pictures to #desig by Sunday before deadline [4/4] +*:led1:post picture of powered LEDs in layout to #desig [6/6]  
-*:led1:post picture of powered LEDs in layout 1 to #desig [6/6]  +*:led1:grabit on the code on lab46 by Sunday before deadline [3/3
-*:led1:post picture of powered LEDs in layout to #desig [6/6]  +*:led1:led1.c code adequately expanded per project requirements [6/6] 
-*:led1:grabit the code on lab46 by Sunday before deadline [2/2+*:led1:led1.c comments describing what is happening [6/6
-*:led1:led1.c code adequately expanded for layouts 1 and 2 [5/5+*:led1:updated code is pushed to lab46 repository [6/6]
-*:led1:updated code is pushed to lab46 repository [4/4]+
 </code> </code>
  
haas/fall2020/common/projects/led1.txt · Last modified: 2021/09/05 10:01 by 127.0.0.1