48f1cdfd0ee48b7c45be40f21b9970e9734d0ddf
haas/fall2026/c4eng/projects/stl2.md
| ... | ... | @@ -0,0 +1,195 @@ |
| 1 | +# ENGR1050 C for Engineers |
|
| 2 | + |
|
| 3 | +# PROJECT: Seeing The Light (STL2) |
|
| 4 | + |
|
| 5 | +## OBJECTIVE |
|
| 6 | + |
|
| 7 | +Time to explore optimizing our logic further, through the use of a loop |
|
| 8 | +and demonstrating the effectiveness of our logic by scaling up the number |
|
| 9 | +of LEDs in our counter (using the 10 segment LED bar). |
|
| 10 | + |
|
| 11 | +## OBTAIN THE PROJECT FILES |
|
| 12 | + |
|
| 13 | +To assist with consistency across all implementations, data files for use |
|
| 14 | +with this project are available on lab46 as a `grabit`, or within the |
|
| 15 | +class repository under the `projects/` directory. Please copy the data to |
|
| 16 | +your project directory in your private semester repository to begin work. |
|
| 17 | + |
|
| 18 | +Please study any provided code or supporting documents, and look up, |
|
| 19 | +experiment, and ask questions on aspects that you do not understand. |
|
| 20 | + |
|
| 21 | +## OPERATING THE PROJECT |
|
| 22 | + |
|
| 23 | +These projects will have two paths to them, depending on which device you |
|
| 24 | +are using: |
|
| 25 | + |
|
| 26 | + * Raspberry Pi single board computer (4/5) using the `wiringPi` library |
|
| 27 | + * Raspberry Pi Pico microcontroller |
|
| 28 | + |
|
| 29 | +``` |
|
| 30 | +lab46:~/SEMESTER/c4eng/stl2$ make |
|
| 31 | +Please select which development environment: |
|
| 32 | + |
|
| 33 | + make wiringpi - using the Raspberr Pi with wiringpi library |
|
| 34 | + make pico - using the Raspberry Pi pico |
|
| 35 | + |
|
| 36 | +after which, you can use 'make' to build |
|
| 37 | +lab46:~/SEMESTER/c4eng/stl2$ |
|
| 38 | +``` |
|
| 39 | + |
|
| 40 | +Run the `make` command with the category representing the path you will |
|
| 41 | +be working with for this project. |
|
| 42 | + |
|
| 43 | +After which, if you do an `ls`, you will see a cyan-colored file called |
|
| 44 | +`stl2.c`. This is the C file you will be editing for this project. |
|
| 45 | + |
|
| 46 | +Go ahead and view it, study the code, eventually make any changes, save |
|
| 47 | +and return to the command-line. |
|
| 48 | + |
|
| 49 | +To build it, you simply run: `make` |
|
| 50 | + |
|
| 51 | +If there are no errors, it will build, and you proceed from there. |
|
| 52 | + |
|
| 53 | + |
|
| 54 | +## MAINTAINING YOUR REPOSITORY |
|
| 55 | + |
|
| 56 | +Be sure to keep your repository up-to-date, regularly committing changes |
|
| 57 | +to files. |
|
| 58 | + |
|
| 59 | +As a reminder, here are the suggested steps: |
|
| 60 | + |
|
| 61 | + -1. `make clean` <-- remove all unnecessary files |
|
| 62 | + 0. `git status` <-- see the current state of things |
|
| 63 | + 1. `git pull` <-- pull down any changes from elsewhere |
|
| 64 | + 2. `git add` <-- add each new or modified file |
|
| 65 | + 2a. `git add ./` <-- try this the first time |
|
| 66 | + 3. `git commit -m "your message" <-- make a snapshot |
|
| 67 | + 4. `git push` |
|
| 68 | + |
|
| 69 | +## TASK |
|
| 70 | + |
|
| 71 | +After exploring, assembling, and testing the intended circuit (10 LEDs), |
|
| 72 | +adapt the provided C code to use the bank of connected LEDs to count in |
|
| 73 | +binary from 0000000000 to at least 1111111111 (0 to 1023). |
|
| 74 | + |
|
| 75 | +Using the current value of count, your task is to make use of ONE **if** |
|
| 76 | +statement and copious use of **bitwise logic** to determine from an |
|
| 77 | +ongoing count the state of the individual bits. |
|
| 78 | + |
|
| 79 | +It is your task to write a C program that interfaces successfully with |
|
| 80 | +the eight or more independently connected LED circuits, arranged in some |
|
| 81 | +orientation to ascertain an order or positioning, where your program will |
|
| 82 | +(in endless fashion, or until being manually interrupted) display a count |
|
| 83 | +(in binary) of values from 0 to 1023 (then rollover, or reset). |
|
| 84 | + |
|
| 85 | +If "1" means the LED in that position is ON, and "0" means the LED in |
|
| 86 | +that position is OFF, then you want to write a program that performs the |
|
| 87 | +following progression (over and over again): |
|
| 88 | + |
|
| 89 | +``` |
|
| 90 | +0 0 0 0 0 0 0 0 0 0 |
|
| 91 | +0 0 0 0 0 0 0 0 0 1 |
|
| 92 | +0 0 0 0 0 0 0 0 1 0 |
|
| 93 | +0 0 0 0 0 0 0 0 1 1 |
|
| 94 | +0 0 0 0 0 0 0 1 0 0 |
|
| 95 | +0 0 0 0 0 0 0 1 0 1 |
|
| 96 | +0 0 0 0 0 0 0 1 1 0 |
|
| 97 | +0 0 0 0 0 0 0 1 1 1 |
|
| 98 | +0 0 0 0 0 0 1 0 0 0 |
|
| 99 | +. . . |
|
| 100 | +1 1 1 1 1 1 1 0 0 1 |
|
| 101 | +1 1 1 1 1 1 1 0 1 0 |
|
| 102 | +1 1 1 1 1 1 1 0 1 1 |
|
| 103 | +1 1 1 1 1 1 1 1 0 0 |
|
| 104 | +1 1 1 1 1 1 1 1 0 1 |
|
| 105 | +1 1 1 1 1 1 1 1 1 0 |
|
| 106 | +1 1 1 1 1 1 1 1 1 1 <-- 1023, the maximum value to display when there are 10 bits/LEDs |
|
| 107 | +0 0 0 0 0 0 0 0 0 0 <-- 0, we "roll over" and start again |
|
| 108 | +0 0 0 0 0 0 0 0 0 1 |
|
| 109 | +0 0 0 0 0 0 0 0 1 0 |
|
| 110 | +. . . |
|
| 111 | +``` |
|
| 112 | + |
|
| 113 | +The circuits you will be constructing will be the same ones we previously |
|
| 114 | +built in class- an LED circuit receiving power (from a GPIO pin), having |
|
| 115 | +a 220 Ohm resistor, an LED, and then connecting to ground. Only this time |
|
| 116 | +we will make use of the 10 segment LED bar. It is basically a packaging |
|
| 117 | +of ten individual LEDs into one component (10 pairs of legs, one pair for |
|
| 118 | +each LED). Remember you still need to hook uip resistors to each LED. |
|
| 119 | + |
|
| 120 | +We will be powering each LED circuit from a unique GPIO pin, allowing for |
|
| 121 | +conditional supply of power, based on our code. |
|
| 122 | + |
|
| 123 | +Unlike in stl1, where you used individual `if` statements to manage each |
|
| 124 | +value of the count, here you will only use **ONE** `if` statement to |
|
| 125 | +manage the state of the current LED. |
|
| 126 | + |
|
| 127 | +## EXECUTION |
|
| 128 | + |
|
| 129 | +If on the pico, follow the process for downloading the binary file and |
|
| 130 | +programming your pico. |
|
| 131 | + |
|
| 132 | +If on the full Raspberry Pi, you have a green executable you can run just |
|
| 133 | +as we've done in our other projects. |
|
| 134 | + |
|
| 135 | +## STRATEGY |
|
| 136 | + |
|
| 137 | +The general flow of the process (one way of going about it, anyway) can |
|
| 138 | +be described as follows: |
|
| 139 | + |
|
| 140 | +``` |
|
| 141 | +SET COUNTER TO ZERO |
|
| 142 | +REPEAT INFINITELY: |
|
| 143 | + SET PLACE TO ONE |
|
| 144 | + REPEAT UNTIL PLACE IS GREATER THAN TEN: |
|
| 145 | + SHOULD THE PLACE POSITION HAVE A ONE: |
|
| 146 | + ACTIVATE THE PLACE’S LED |
|
| 147 | + OTHERWISE: |
|
| 148 | + DEACTIVATE THE PLACE’S LED |
|
| 149 | + |
|
| 150 | + LET PLACE BECOME THE NEXT PLACE POSITION |
|
| 151 | + KEEP GOING |
|
| 152 | + |
|
| 153 | + PAUSE FOR HUMAN PERCEPTION |
|
| 154 | + LET THE COUNTER BE INCREMENTED BY ONE |
|
| 155 | +KEEP GOING |
|
| 156 | +</code> |
|
| 157 | +``` |
|
| 158 | + |
|
| 159 | +## SUBMISSION |
|
| 160 | + |
|
| 161 | +To successfully complete this project, the following criteria must be |
|
| 162 | +met: |
|
| 163 | + |
|
| 164 | + * Code must compile/execute cleanly (no notes, warnings, nor errors) |
|
| 165 | + * Code must be nicely and consistently indented |
|
| 166 | + * Code must be well commented |
|
| 167 | + * Do NOT double space your code. Group like statements together. |
|
| 168 | + * Track/version the source code in your private semester repository |
|
| 169 | + |
|
| 170 | +To submit this project to me, make sure the `Makefile` and your completed |
|
| 171 | +`stl2.c` file are placed in your private semester repository under |
|
| 172 | +`c4eng/stl2/` |
|
| 173 | + |
|
| 174 | +What I'll be looking for: |
|
| 175 | + |
|
| 176 | +### RUBRIC |
|
| 177 | + |
|
| 178 | +I'll be evaluating the project based on the following criteria: |
|
| 179 | + |
|
| 180 | +``` |
|
| 181 | +182:stl2:final tally of results (182/182) |
|
| 182 | +*:stl2:post a picture or short video to the DISCORD [26/26] |
|
| 183 | +*:stl2:code makes use of ONE if statement [26/26] |
|
| 184 | +*:stl2:code makes use of a for loop [26/26] |
|
| 185 | +*:stl2:code makes use of bitwise logic [26/26] |
|
| 186 | +*:stl2:code structure is different than stl1 [26/26] |
|
| 187 | +*:stl2:program conforms to project specifications [26/26] |
|
| 188 | +*:stl2:code tracked in private semester repo [26/26] |
|
| 189 | +``` |
|
| 190 | + |
|
| 191 | +Additionally: |
|
| 192 | + * Solutions not abiding by spirit of project will be subject to a 50% overall deduction |
|
| 193 | + * Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction |
|
| 194 | + * Solutions not utilizing indentation to promote scope and clarity or otherwise maintaining consistency in code style and presentation will be subject to a 25% overall deduction |
|
| 195 | + * Solutions not organized and easy to read (assume a terminal at least 90 characters wide, 40 characters tall) are subject to a 25% overall deduction |