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
haas:fall2020:common:projects:led1 [2020/08/27 12:19] – [PROJECT] wedgehaas:fall2020:common:projects:led1 [2021/09/05 10:01] (current) – external edit 127.0.0.1
Line 3: Line 3:
  
 =====Objective===== =====Objective=====
-To create a program that generates a unique pattern of lit LEDs on your pi based on constraints+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 enforced 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!)
  
 =====Abstraction===== =====Abstraction=====
Line 16: Line 16:
 Please be sure to familiarize yourself with the following content in "[[https://publications.gbdirect.co.uk//c_book/|the C book]]": Please be sure to familiarize yourself with the following content in "[[https://publications.gbdirect.co.uk//c_book/|the C book]]":
  
-  * [[https://publications.gbdirect.co.uk//c_book/chapter3/|Chapter 3]]+  * [[https://publications.gbdirect.co.uk//c_book/chapter4/|Chapter 4]]
  
 =====Background===== =====Background=====
-For this project, you will be writing a C program using the wiringPi library on the Raspberry Pi, wiring up a red LED to your breadboard and witnessing your ability to control it via software.+For this project, you will be working with a C program using the wiringPi library on the Raspberry Pi, wiring up a set of four red LEDs to your breadboard and witnessing your ability to control them via software.
  
 =====Input and Output via the GPIO pins on the pi===== =====Input and Output via the GPIO pins on the pi=====
Line 33: Line 33:
  
 <cli> <cli>
-yourpi:~/src/desig/led0$ gpio readall+yourpi:~/src/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/led0+yourpi:~/src/desig/led1
 </cli> </cli>
  
Line 81: Line 81:
 It may seem a bit bewildering or overwhelming at first, but like anything, time and exposure will ensure it becomes increasingly second nature. It may seem a bit bewildering or overwhelming at first, but like anything, time and exposure will ensure it becomes increasingly second nature.
  
-=====Wiring up our first circuit===== +=====Wiring up our circuit===== 
-Here we areabout to embark on our first foray into mixing with hardware and software.+This circuit is basically an expansion upon the one you made last week. So the parts needed remains the sameonly expanding in the quantity of certain items as we expand the number of LEDs.
  
-In this project, we will be hooking up a peripheral to a couple of our Raspberry Pi pins: light emitting diode (LED) and supporting hardware, and then proceed to interface with it to control its state (of being ON or OFF).+In this project, we will be hooking up a peripheral to some of our Raspberry Pi pins: light emitting diodes (LED) and supporting hardware, and then proceed to interface with them to control its state (of being ON or OFF).
  
 You have likely encountered LEDs endlessly in your everyday life: commonly used as a "power light", which when lit, indicates the device is powered on, among many, MANY, **MANY** other applications. You have likely encountered LEDs endlessly in your everyday life: commonly used as a "power light", which when lit, indicates the device is powered on, among many, MANY, **MANY** other applications.
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 114: Line 118:
  
 <WRAP info>The plastic rectangle should have a notch cut out from it, and notice that the ribbon cable connector has a notch included in it. That is a key to indicate how you need to connect the ribbon cable into the T-cobbler</WRAP> <WRAP info>The plastic rectangle should have a notch cut out from it, and notice that the ribbon cable connector has a notch included in it. That is a key to indicate how you need to connect the ribbon cable into the T-cobbler</WRAP>
-====(1) red LED==== +====(4) red LEDs==== 
-You have a few LEDs included in your kit, some of notably different colours. Go for one of the distinctly red looking ones, resembling the following:+You have a few LEDs included in your kit, some of notably different colours. Go for four of the distinctly red-looking ones, resembling the following:
  
 {{ :haas:fall2020:common:projects:redled.png?400 |}} {{ :haas:fall2020:common:projects:redled.png?400 |}}
Line 123: Line 127:
 The longer leg is the positive side of the LED, called the “anode,” and the shorter leg is the negative side, called the “cathode.” Within an LED, current can only flow from the anode (positive side) to the cathode (negative side) and never in the opposite direction. The longer leg is the positive side of the LED, called the “anode,” and the shorter leg is the negative side, called the “cathode.” Within an LED, current can only flow from the anode (positive side) to the cathode (negative side) and never in the opposite direction.
  
-====(1) 220 Ohm resistor==== +====(4) 220 Ohm resistors==== 
-Your kit should come with 3-4 packs of differently rated resistors (220, 1K, and 10K). You want ONE of the lowest rated ones, the 220 ohm variety. You should see the value marked on the paper strip holding the legs of the resistors.+Your kit should come with 3-4 packs of differently rated resistors (220, 1K, and 10K). You want FOUR of the lowest rated ones, the 220 ohm variety. You should see the value marked on the paper strip holding the legs of the resistors.
  
 {{ :haas:fall2020:common:projects:220ohm_resistor.jpg?400 |}} {{ :haas:fall2020:common:projects:220ohm_resistor.jpg?400 |}}
Line 131: Line 135:
  
 <WRAP round info>Unlike the LED, where the direction of connection matters, it does not matter which way you plug in a resistor. Its purpose is simply to resist.</WRAP> <WRAP round info>Unlike the LED, where the direction of connection matters, it does not matter which way you plug in a resistor. Its purpose is simply to resist.</WRAP>
 +
 ====male to male jumper wire, as needed==== ====male to male jumper wire, as needed====
 As a final piece of equipment you will need, locate and have a few male-to-male jumper wires handy for use in our circuit: As a final piece of equipment you will need, locate and have a few male-to-male jumper wires handy for use in our circuit:
Line 137: Line 142:
  
 =====The Circuit to Construct===== =====The Circuit to Construct=====
-With those components, you will want to place them onto your breadboard in a manner similar to this:+With those components, you will want to place them onto your breadboard, expanding upon last week's circuit (picture of last week's circuit provided):
  
 {{ :haas:fall2020:common:projects:led_circuit.png?400 |}} {{ :haas:fall2020:common:projects:led_circuit.png?400 |}}
Line 143: 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: 
 + 
 +  * EACH LED needs to be interfaced with a unique GPIO pin 
 +  * EACH LED needs a corresponding resistor (no sharing!) Forgetting to use the resistor can lead to damage to the LED! 
 +  * ground connections can be shared (we call this "common ground"
 +  * take note of which GPIO pin you are using, so can update the led1.c program
  
-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 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 164: Line 177:
  
 <cli> <cli>
-yourpi:~/src/desig/led0$ gpio mode 0 OUT+yourpi:~/src/desig/led1$ gpio mode 0 OUT
 </cli> </cli>
  
Line 180: 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 188: 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 compile, run, and understand a program to interface with an LED (light emitting diode), a nice software-hardware connection, on your raspberry pi.+It is your task to compile, run, expand upon, and understand a program to interface with a set of LEDs (light emitting diodes), a nice software-hardware connection, on your raspberry pi.
  
-The program files provided for this project are complete. You merely have to get it on your pi, compile it, and run it, with the appropriate circuitry hooked up to the specified places. You will want to make sure you UNDERSTAND what is going on.+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 QUESTIONS, and do so EARLY enough so that you aren't in a mad dash to make the deadline.
  
 In future projects you will start implementing more logic to attain further functionality. In future projects you will start implementing more logic to attain further functionality.
Line 199: Line 213:
  
 <cli> <cli>
-lab46:~/src/desig$ grabit desig led0 +lab46:~/src/desig$ grabit desig led1 
-make: Entering directory '/var/public/SEMESTER/desig/lob0+make: Entering directory '/var/public/SEMESTER/desig/led1
-'/var/public/SEMESTER/desig/led0/Makefile' -> '/home/user/src/desig/led0/Makefile' +'/var/public/SEMESTER/desig/led1/Makefile' -> '/home/user/src/desig/led1/Makefile' 
-'/var/public/SEMESTER/desig/led0/led0.c' -> '/home/user/src/desig/led0/led0.c' +'/var/public/SEMESTER/desig/led1/led1.c' -> '/home/user/src/desig/led1/led1.c' 
-make: Leaving directory '/var/public/SEMESTER/desig/led0'+make: Leaving directory '/var/public/SEMESTER/desig/led1'
 lab46:~/src/desig$  lab46:~/src/desig$ 
 </cli> </cli>
  
-At which point you can change into the newly created and populated **led0** directory.+At which point you can change into the newly created and populated **led1** directory.
  
 ====Getting project resources from lab46 to your pi==== ====Getting project resources from lab46 to your pi====
Line 227: Line 241:
  
 ===Installing wiringpi=== ===Installing wiringpi===
 +<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:
  
 <cli> <cli>
-yourpi:~/src/desig/led0$ gpio readall+yourpi:~/src/desig/led1$ gpio readall
 Oops - unable to determine board type... model: 17 Oops - unable to determine board type... model: 17
 </cli> </cli>
Line 237: Line 253:
  
 <cli> <cli>
-yourpi:~/src/desig/led0$ wget https://project-downloads.drogon.net/wiringpi-latest.deb+yourpi:~/src/desig/led1$ wget https://project-downloads.drogon.net/wiringpi-latest.deb
 ... ...
-yourpi:~/src/desig/led0$ sudo dpkg -i wiringpi-latest.deb+yourpi:~/src/desig/led1$ sudo dpkg -i wiringpi-latest.deb
 ... ...
-yourpi:~/src/desig/led0$ rm -f wiringpi-latest.deb+yourpi:~/src/desig/led1$ rm -f wiringpi-latest.deb
 </cli> </cli>
  
Line 271: Line 287:
  
 <cli> <cli>
-lab46:~/src/desig/led0$ submit desig led0 led0.c +lab46:~/src/desig/led1$ submit desig led1 led1.c 
-Submitting desig project "led0": +Submitting desig project "led1": 
-    -> led0.c(OK)+    -> led1.c(OK)
  
 SUCCESSFULLY SUBMITTED SUCCESSFULLY SUBMITTED
Line 283: Line 299:
  
 <code> <code>
-26:led0:final tally of results (26/26+39:led1:final tally of results (39/39
-*:led0:post picture of unpowered layout to #desig and get approval [6/6] +*:led1:post picture of unpowered layout to #desig and get approval [6/6] 
-*:led0:post picture to #desig by Sunday before deadline [4/4+*:led1:post picture to #desig by Sunday before deadline [6/6
-*:led0:post picture of powered LED to #desig [6/6]  +*:led1:post picture of powered LEDs in layout to #desig [6/6]  
-*:led0:grabit the code on lab46 by Sunday before deadline [4/4+*:led1:grabit on the code on lab46 by Sunday before deadline [3/3] 
-*:led0:code is pushed to lab46 repository [6/6]+*:led1:led1.c code adequately expanded per project requirements [6/6] 
 +*:led1:led1.c comments describing what is happening [6/6
 +*:led1:updated code is pushed to lab46 repository [6/6]
 </code> </code>
  
Line 296: Line 314:
   * 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/fall2020/common/projects/led1.1598545157.txt.gz · Last modified: 2020/08/27 12:19 by wedge