User Tools

Site Tools


haas:fall2021:common:projects:led1

Differences

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

Link to this comparison view

Next revision
Previous revision
haas:fall2021:common:projects:led1 [2020/09/18 13:28] – external edit 127.0.0.1haas:fall2021:common:projects:led1 [2021/09/12 22:54] (current) – [Process] wedge
Line 8: Line 8:
  
 =====Abstraction===== =====Abstraction=====
-{{page>haas:fall2020:common:projects:abstraction&noheader}}+{{page>haas:fall2021:common:projects:abstraction&noheader}}
  
 =====Locational Awareness===== =====Locational Awareness=====
-{{page>haas:fall2020:common:projects:location&noheader}}+{{page>haas:fall2021:common:projects:location&noheader}}
  
 =====Reading===== =====Reading=====
Line 33: Line 33:
  
 <cli> <cli>
-yourpi:~/src/desig/led1$ gpio readall+yourpi:~/src/SEMESTER/DESIG/led1$ gpio readall
  +-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+  +-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+
  | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |  | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
Line 60: Line 60:
  | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |  | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
  +-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+  +-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+
-yourpi:~/src/desig/led1$ +yourpi:~/src/SEMESTER/DESIG/led1$ 
 </cli> </cli>
  
Line 177: Line 177:
  
 <cli> <cli>
-yourpi:~/src/desig/led1$ gpio mode 0 OUT+yourpi:~/src/SEMESTER/DESIG/led1$ gpio mode 0 OUT
 </cli> </cli>
  
Line 193: Line 193:
  
 <cli> <cli>
-yourpi:~/src/desig/led1$ gpio write 0 1      ## activate voltage on wiringpi pin 0 (turn on) +yourpi:~/src/SEMESTER/DESIG/led1$ gpio write 0 1      ## activate voltage on wiringpi pin 0 (turn on) 
-yourpi:~/src/desig/led1$ gpio write 0 0      ## deactivate voltage on wiringpi pin 0 (turn off)+yourpi:~/src/SEMESTER/DESIG/led1$ gpio write 0 0      ## deactivate voltage on wiringpi pin 0 (turn off)
 </cli> </cli>
  
Line 203: Line 203:
 With an expanded set of LED circuits, be sure to test the operation of each one. 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:
  
 <cli> <cli>
-lab46:~/src/desig$ grabit desig led1+lab46:~/src/SEMESTER/DESIG$ grabit desig led1
 make: Entering directory '/var/public/SEMESTER/desig/led1' make: Entering directory '/var/public/SEMESTER/desig/led1'
-'/var/public/SEMESTER/desig/led1/Makefile' -> '/home/user/src/desig/led1/Makefile' +'/var/public/SEMESTER/desig/led1/Makefile' -> '/home/user/src/SEMESTER/DESIG/led1/Makefile' 
-'/var/public/SEMESTER/desig/led1/led1.c' -> '/home/user/src/desig/led1/led1.c'+'/var/public/SEMESTER/desig/led1/led1.c' -> '/home/user/src/SEMESTER/DESIG/led1/led1.c'
 make: Leaving directory '/var/public/SEMESTER/desig/led1' make: Leaving directory '/var/public/SEMESTER/desig/led1'
-lab46:~/src/desig+lab46:~/src/SEMESTER/DESIG
 </cli> </cli>
  
Line 233: 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 246: Line 346:
  
 <cli> <cli>
-yourpi:~/src/desig/led1$ gpio readall+yourpi:~/src/SEMESTER/DESIG/led1$ gpio readall
 Oops - unable to determine board type... model: 17 Oops - unable to determine board type... model: 17
 </cli> </cli>
Line 253: Line 353:
  
 <cli> <cli>
-yourpi:~/src/desig/led1$ wget https://project-downloads.drogon.net/wiringpi-latest.deb+yourpi:~/src/SEMESTER/DESIG/led1$ wget https://project-downloads.drogon.net/wiringpi-latest.deb
 ... ...
-yourpi:~/src/desig/led1$ sudo dpkg -i wiringpi-latest.deb+yourpi:~/src/SEMESTER/DESIG/led1$ sudo dpkg -i wiringpi-latest.deb
 ... ...
-yourpi:~/src/desig/led1$ rm -f wiringpi-latest.deb+yourpi:~/src/SEMESTER/DESIG/led1$ rm -f wiringpi-latest.deb
 </cli> </cli>
  
Line 271: Line 371:
 When done and ready to submit, on lab46: **make submit** When done and ready to submit, on lab46: **make submit**
  
 +=====Process=====
 +The general flow of the process (one way of going about it, anyway) can be described as follows:
 +
 +<code>
 +number <- 0
 +loop (endlessly)
 +    if the number is zero
 +        activate/deactivate the four LEDs to represent zero
 +
 +    if the number is one
 +        activate/deactivate the four LEDs to represent one
 +       
 +    if the number is two
 +        activate/deactivate the four LEDs to represent two
 +
 +    ... on and on through the cases for the remaining numbers
 +
 +    strategic delay so you can see the current number
 +
 +    let the number increment by one, but not to exceed fifteen
 +done
 +</code>
 =====Submission===== =====Submission=====
 To successfully complete this project, the following criteria must be met: To successfully complete this project, the following criteria must be met:
Line 287: Line 409:
  
 <cli> <cli>
-lab46:~/src/desig/led1$ submit desig led1 led1.c +lab46:~/src/SEMESTER/DESIG/led1$ make submit
-Submitting desig project "led1": +
-    -> led1.c(OK) +
- +
-SUCCESSFULLY SUBMITTED+
 </cli> </cli>
  
Line 314: Line 432:
   * Solutions not utilizing indentation to promote scope and clarity will be subject to a 25% overall deduction   * Solutions not utilizing indentation to promote scope and clarity will be subject to a 25% overall deduction
   * Solutions not organized and easy to read are subject to a 25% overall deduction   * Solutions not organized and easy to read are subject to a 25% overall deduction
 +
haas/fall2021/common/projects/led1.1600435714.txt.gz · Last modified: 2020/09/18 13:28 by 127.0.0.1