User Tools

Site Tools


haas:fall2020:common:projects:led2

Differences

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

Link to this comparison view

Next revision
Previous revision
haas:fall2020:common:projects:led2 [2020/09/03 16:48] – created wedgehaas:fall2020:common:projects:led2 [2020/09/20 16:53] (current) – [Program] wedge
Line 1: Line 1:
 ======PROJECT====== ======PROJECT======
-PROJECT: Light Emitting Diodes (led1)+PROJECT: Light Emitting Diodes (led2)
  
 =====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 a 10 LED block package and generating a "swoosh" pattern of lit LEDs with it on your pi.
  
 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 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/chapter4/|Chapter 4]]+  * [[https://publications.gbdirect.co.uk//c_book/chapter5/|Chapter 5]]
  
 =====Background===== =====Background=====
-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.+For this project, you will be working with a C program using the wiringPi library on the Raspberry Pi, wiring up a 10 LED block package 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/led1$ gpio readall+yourpi:~/src/desig/led2$ 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/desig/led2
 </cli> </cli>
  
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>
-====(4red LEDs==== +====(110 LED block package====
-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 |}}+10 LEDs, all in one convenient package!
  
-Do note that the two legs of the LED are not equal in length.+{{ :haas:fall2020:common:projects:ledbar.png?400 |}}
  
-The longer leg is the positive side of the LEDcalled 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 package has a set of pinswhich allow us to hook each LED up as we would if they were separate:
  
-====(4) 220 Ohm resistors==== +{{ :haas:fall2020:common:projects:ledbarpins.png?400 |}} 
-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.+====(10) 220 Ohm resistors==== 
 +Your kit should come with 3-4 packs of differently rated resistors (220, 1K, and 10K). You want TEN of the lowest rated ones, the 220 ohm variety. One for each LED. 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 138: Line 142:
  
 =====The Circuit to Construct===== =====The Circuit to Construct=====
-With those components, you will want to place them onto your breadboard, expanding upon last week's circuit (picture of last week'circuit provided):+With those components, you will want to place them onto your breadboard, in a manner similar to last week's circuit, but obviously with a lot more going on. Here is the circuit diagram you are assembling:
  
-{{ :haas:fall2020:common:projects:led_circuit.png?400 |}}+{{ :haas:fall2020:common:projects:ledbarcircuit.png?400 |}}
  
 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" 
  
 Please keep in mind: Please keep in mind:
Line 151: Line 153:
   * EACH LED needs a corresponding resistor (no sharing!) Forgetting to use the resistor can lead to damage to the LED!   * 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")   * 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+  * take note of which GPIO pin you are using, so can update the led2.c program
  
-<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 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 173: Line 174:
  
 <cli> <cli>
-yourpi:~/src/desig/led1$ gpio mode 0 OUT+yourpi:~/src/desig/led2$ gpio mode 0 OUT
 </cli> </cli>
  
Line 189: Line 190:
  
 <cli> <cli>
-yourpi:~/src/desig/led1$ gpio write 0 1      ## activate voltage on wiringpi pin 0 (turn on) +yourpi:~/src/desig/led2$ 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/desig/led2$ gpio write 0 0      ## deactivate voltage on wiringpi pin 0 (turn off)
 </cli> </cli>
  
Line 201: Line 202:
 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. 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, 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 a mad dash to make the deadline.+You aim for this project is to write a program that will get all 10 LEDs in the LED bar to "swoosh" from left to right, that is:
  
-In future projects you will start implementing more logic to attain further functionality.+  * initially start off 
 +  * one at a time (on a constant update delay) activate each LED, from left to right, until each LED is lit up 
 +  * then, one at a time (on the same constant update delay), deactivate each LED, from left to right, until each LED is no longer lit 
 +  * the program can continually perform this swooshing pattern, but it should do the whole pattern at least once
  
 +{{ :haas:fall2020:common:projects:swoosh.gif |}}
 ====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/desig$ grabit desig led2 
-make: Entering directory '/var/public/SEMESTER/desig/led1+make: Entering directory '/var/public/SEMESTER/desig/led2
-'/var/public/SEMESTER/desig/led1/Makefile' -> '/home/user/src/desig/led1/Makefile' +'/var/public/SEMESTER/desig/led2/Makefile' -> '/home/user/src/desig/led2/Makefile' 
-'/var/public/SEMESTER/desig/led1/led1.c' -> '/home/user/src/desig/led1/led1.c' +'/var/public/SEMESTER/desig/led2/led2.c' -> '/home/user/src/desig/led2/led2.c' 
-make: Leaving directory '/var/public/SEMESTER/desig/led1'+make: Leaving directory '/var/public/SEMESTER/desig/led2'
 lab46:~/src/desig$  lab46:~/src/desig$ 
 </cli> </cli>
  
-At which point you can change into the newly created and populated **led1** directory.+At which point you can change into the newly created and populated **led2** directory.
  
 ====Getting project resources from lab46 to your pi==== ====Getting project resources from lab46 to your pi====
Line 242: Line 247:
  
 <cli> <cli>
-yourpi:~/src/desig/led1$ gpio readall+yourpi:~/src/desig/led2$ gpio readall
 Oops - unable to determine board type... model: 17 Oops - unable to determine board type... model: 17
 </cli> </cli>
Line 249: Line 254:
  
 <cli> <cli>
-yourpi:~/src/desig/led1$ wget https://project-downloads.drogon.net/wiringpi-latest.deb+yourpi:~/src/desig/led2$ wget https://project-downloads.drogon.net/wiringpi-latest.deb
 ... ...
-yourpi:~/src/desig/led1$ sudo dpkg -i wiringpi-latest.deb+yourpi:~/src/desig/led2$ sudo dpkg -i wiringpi-latest.deb
 ... ...
-yourpi:~/src/desig/led1$ rm -f wiringpi-latest.deb+yourpi:~/src/desig/led2$ rm -f wiringpi-latest.deb
 </cli> </cli>
  
Line 283: Line 288:
  
 <cli> <cli>
-lab46:~/src/desig/led1$ submit desig led1 led1.c +lab46:~/src/desig/led2$ submit desig led2 led2.c 
-Submitting desig project "led1": +Submitting desig project "led2": 
-    -> led1.c(OK)+    -> led2.c(OK)
  
 SUCCESSFULLY SUBMITTED SUCCESSFULLY SUBMITTED
Line 296: Line 301:
 <code> <code>
 52:led2:final tally of results (52/52) 52:led2:final tally of results (52/52)
-*:led2:post picture of unpowered layout to #desig and get approval [6/6+*:led2:post picture of unpowered layout to #desig and get approval [8/8
-*:led2:post picture to #desig by Sunday before deadline [6/6+*:led2:post picture to #desig by Sunday before deadline [4/4
-*:led2:post picture of powered LEDs in layout to #desig [6/6]  +*:led2:post picture of powered LEDs in layout to #desig [8/8]  
-*:led2:grabit on the code on lab46 by Sunday before deadline [3/3+*:led2:grabit on the code on lab46 by Sunday before deadline [4/4
-*:led2:led2.c code adequately expanded per project requirements [6/6+*:led2:led2.c code adequately modified per project requirements [12/12
-*:led2:led2.c comments describing what is happening [6/6+*:led2:led2.c comments describing what is happening [8/8
-*:led2:updated code is pushed to lab46 repository [6/6]+*:led2:updated code is pushed to lab46 repository [8/8]
 </code> </code>
  
haas/fall2020/common/projects/led2.1599166080.txt.gz · Last modified: 2020/09/03 16:48 by wedge