a008950d7384f79f08c616683250650381d3b039
haas/fall2026/c4eng/projects/ptb1.md
| ... | ... | @@ -0,0 +1,221 @@ |
| 1 | +# ENGR1050 C for Engineers |
|
| 2 | + |
|
| 3 | +# PROJECT: Press The Button (PTB1) |
|
| 4 | + |
|
| 5 | +## OBJECTIVE |
|
| 6 | + |
|
| 7 | +Buttons and multi-colored LEDs, oh my! |
|
| 8 | + |
|
| 9 | +## PROCESS |
|
| 10 | + |
|
| 11 | +Do note, the productive way to go about this project involves taking the |
|
| 12 | +following steps: |
|
| 13 | + |
|
| 14 | + * starting early |
|
| 15 | + * reading the project page |
|
| 16 | + * asking questions regarding things you do not know, are not clear on, |
|
| 17 | + or are confused about |
|
| 18 | + * as information, concepts, processes become clear, that is something |
|
| 19 | + you can contribute to the project documentation (so you can better |
|
| 20 | + remember) |
|
| 21 | + |
|
| 22 | +If you start too late, and do not ask questions, and do not have enough |
|
| 23 | +time and don't know what is going on, you are not doing the project |
|
| 24 | +correctly. |
|
| 25 | + |
|
| 26 | +## OBTAIN THE PROJECT FILES |
|
| 27 | + |
|
| 28 | +To assist with consistency across all implementations, data files for use |
|
| 29 | +with this project are available on lab46 as a `grabit`. Please copy the |
|
| 30 | +data to your private semester repository under an appropriate project |
|
| 31 | +directory to begin work, and ensure your implementation properly works |
|
| 32 | +with the provided data. |
|
| 33 | + |
|
| 34 | +The project should be obtained by the **Sunday prior to the due date**. |
|
| 35 | + |
|
| 36 | +``` |
|
| 37 | +lab46:~/SEMESTER/c4eng$ grabit c4eng ptb1 |
|
| 38 | +``` |
|
| 39 | + |
|
| 40 | +Please study any provided code or supporting documents, and look up, |
|
| 41 | +experiment, and ask questions on aspects that you do not understand. |
|
| 42 | + |
|
| 43 | +## OPERATING THE PROJECT |
|
| 44 | + |
|
| 45 | +These projects will have two paths to them, depending on which device you |
|
| 46 | +are using: |
|
| 47 | + |
|
| 48 | + * Raspberry Pi single board computer (4/5) using the `wiringPi` library |
|
| 49 | + * Raspberry Pi Pico microcontroller |
|
| 50 | + |
|
| 51 | +``` |
|
| 52 | +lab46:~/SEMESTER/c4eng/ptb1$ make |
|
| 53 | +Please select which development environment: |
|
| 54 | + |
|
| 55 | + make wiringpi - using the Raspberry Pi with wiringpi library |
|
| 56 | + make pico - using the Raspberry Pi pico |
|
| 57 | + |
|
| 58 | +after which, you can use 'make' to build |
|
| 59 | +lab46:~/SEMESTER/c4eng/ptb1$ |
|
| 60 | +``` |
|
| 61 | + |
|
| 62 | +Run the `make` command with the category representing the path you will |
|
| 63 | +be working with for this project. |
|
| 64 | + |
|
| 65 | +After which, if you do an `ls`, you will see a cyan-colored file called |
|
| 66 | +`ptb1.c`. This is the C file you will be editing for this project. |
|
| 67 | + |
|
| 68 | +Go ahead and view it, study the code, eventually make any changes, save |
|
| 69 | +and return to the command-line. |
|
| 70 | + |
|
| 71 | +To build it, you simply run: `make` |
|
| 72 | + |
|
| 73 | +If there are no errors, it will build, and you proceed from there. |
|
| 74 | + |
|
| 75 | +## MAINTAINING YOUR REPOSITORY |
|
| 76 | + |
|
| 77 | +Be sure to keep your repository up-to-date, regularly committing changes |
|
| 78 | +to files. |
|
| 79 | + |
|
| 80 | +As a reminder, here are the suggested steps: |
|
| 81 | + |
|
| 82 | + -1. `make clean` <-- remove all unnecessary files |
|
| 83 | + 0. `git status` <-- see the current state of things |
|
| 84 | + 1. `git pull` <-- pull down any changes from elsewhere |
|
| 85 | + 2. `git add` <-- add each new or modified file |
|
| 86 | + 2a. `git add ./` <-- try this the first time |
|
| 87 | + 3. `git commit -m "your message"` <-- make a snapshot |
|
| 88 | + 4. `git push` |
|
| 89 | + |
|
| 90 | +## TASK |
|
| 91 | + |
|
| 92 | +Taking our knowledge of LEDs and buttons: |
|
| 93 | + |
|
| 94 | + * wire up the multicolored LED (3 separate GPIO pins) |
|
| 95 | + * we are going to use PWM to control this, which will give |
|
| 96 | + us 100 levels of adjustment |
|
| 97 | + * wire up 3 buttons to additional, individual GPIOs (one for red, one |
|
| 98 | + for green, one for blue) |
|
| 99 | + * wire up the rocker switch to its own unique GPIO |
|
| 100 | + * one direction will indicate positive |
|
| 101 | + * the other direction will indicate negative |
|
| 102 | + * implement logic so that, with the rocker switch in a given position, |
|
| 103 | + when pressing one of the color buttons, it adjusts that component of |
|
| 104 | + the multicolor LED in the appropriate direction (by a step of 10). |
|
| 105 | + * if a color value exceeds or dips below the allowed range, cycle it |
|
| 106 | + to the opposite end |
|
| 107 | + |
|
| 108 | +Each LED color channel is powered from a unique GPIO pin, allowing for |
|
| 109 | +independent control of the red, green, and blue components. Likewise, |
|
| 110 | +each button and the rocker switch will be connected to its own unique |
|
| 111 | +GPIO pin, which your program will read to determine whether that button |
|
| 112 | +is currently being pressed, and which direction the switch is set to. |
|
| 113 | + |
|
| 114 | +## EXECUTION |
|
| 115 | + |
|
| 116 | +If on the pico, follow the process for downloading the binary file and |
|
| 117 | +programming your pico. |
|
| 118 | + |
|
| 119 | +If on the full Raspberry Pi, you have a green executable you can run just |
|
| 120 | +as we've done in our other projects. |
|
| 121 | + |
|
| 122 | +## STRATEGY |
|
| 123 | + |
|
| 124 | +The general flow of the process (one way of going about it, anyway) can |
|
| 125 | +be described as follows: |
|
| 126 | + |
|
| 127 | +``` |
|
| 128 | +SET REDVAL, GRNVAL, BLUVAL TO ZERO |
|
| 129 | +REPEAT INFINITELY: |
|
| 130 | + SHOULD THE INCREMENT POSITION ON THE SWITCH BE SET: |
|
| 131 | + SET DIRECTION TO POSITIVE ONE |
|
| 132 | + OTHERWISE: |
|
| 133 | + SET DIRECTION TO NEGATIVE ONE |
|
| 134 | + |
|
| 135 | + SHOULD THE RED BUTTON BE PRESSED: |
|
| 136 | + ADJUST REDVAL BY (TEN TIMES DIRECTION) |
|
| 137 | + |
|
| 138 | + SHOULD THE GREEN BUTTON BE PRESSED: |
|
| 139 | + ADJUST GRNVAL BY (TEN TIMES DIRECTION) |
|
| 140 | + |
|
| 141 | + SHOULD THE BLUE BUTTON BE PRESSED: |
|
| 142 | + ADJUST BLUVAL BY (TEN TIMES DIRECTION) |
|
| 143 | + |
|
| 144 | + ACTIVATE MULTICOLOR LED TO RGB VALUES CURRENTLY SET |
|
| 145 | + |
|
| 146 | + DELAY AT LEAST FIFTY MILLISECONDS |
|
| 147 | + |
|
| 148 | +REPEAT BLOCK |
|
| 149 | +``` |
|
| 150 | + |
|
| 151 | +## SUBMISSION |
|
| 152 | + |
|
| 153 | +To be successful in this project, the following criteria (or their |
|
| 154 | +equivalent) must be met: |
|
| 155 | + |
|
| 156 | + * Project must be submit on time, by the deadline. |
|
| 157 | + * Late submissions will lose 33% credit per day, with the submission |
|
| 158 | + window closing on the 3rd day following the deadline. |
|
| 159 | + * All code must compile cleanly (no warnings or errors) |
|
| 160 | + * Compile with the `-Wall` and `--std=gnu18` compiler flags |
|
| 161 | + * All requested functionality must conform to stated requirements |
|
| 162 | + (either in this document or in a comment banner in the source code |
|
| 163 | + files themselves). |
|
| 164 | + * Executed programs must display in a manner similar to provided output |
|
| 165 | + * Output formatted, where applicable, must match that of project |
|
| 166 | + requirements |
|
| 167 | + * Processing must be correct based on input given and output requested |
|
| 168 | + * Output, if applicable, must be correct based on values input |
|
| 169 | + * Code must be nicely and consistently indented |
|
| 170 | + * Code must be consistently written, to strive for readability from |
|
| 171 | + having a consistent style throughout |
|
| 172 | + * Code must be commented |
|
| 173 | + * Any "to be implemented" comments **MUST** be removed |
|
| 174 | + * These "to be implemented" comments, if still present at |
|
| 175 | + evaluation time, will result in points being deducted. |
|
| 176 | + * Sufficient comments explaining the point of provided logic **MUST** |
|
| 177 | + be present |
|
| 178 | + * No global variables (without instructor approval), no goto |
|
| 179 | + statements, no calling of main()! |
|
| 180 | + * Track/version the source code in your lab46 semester repository |
|
| 181 | + * Submit a copy of your source code to me using the `submit` tool |
|
| 182 | + (`make submit` on lab46 will do this) by the deadline. |
|
| 183 | + |
|
| 184 | +### Submit Tool Usage |
|
| 185 | + |
|
| 186 | +Let's say you have completed work on the project, and are ready to |
|
| 187 | +submit, you would do the following: |
|
| 188 | + |
|
| 189 | +``` |
|
| 190 | +lab46:~/SEMESTER/c4eng/ptb1$ make submit |
|
| 191 | +``` |
|
| 192 | + |
|
| 193 | +You should get some sort of confirmation indicating successful submission |
|
| 194 | +if all went according to plan. If not, check for typos and or locational |
|
| 195 | +mismatches. |
|
| 196 | + |
|
| 197 | +What I'll be looking for: |
|
| 198 | + |
|
| 199 | +### RUBRIC |
|
| 200 | + |
|
| 201 | +I'll be evaluating the project based on the following criteria: |
|
| 202 | + |
|
| 203 | +``` |
|
| 204 | +234:ptb1:final tally of results (234/234) |
|
| 205 | +*:ptb1:used grabit to obtain project by the Sunday prior to duedate [13/13] |
|
| 206 | +*:ptb1:post a screenshot or short video to the class DISCORD [13/13] |
|
| 207 | +*:ptb1:each color of the multicolor LED hooked to a unique GPIO [26/26] |
|
| 208 | +*:ptb1:each button and the rocker switch hooked to unique GPIOs [26/26] |
|
| 209 | +*:ptb1:switch is read and adjusts color level direction [39/39] |
|
| 210 | +*:ptb1:each button adjusts its pertinent color level [39/39] |
|
| 211 | +*:ptb1:multicolor LED displays current set RGB levels [39/39] |
|
| 212 | +*:ptb1:bounds enforcement keeping color value within range [26/26] |
|
| 213 | +*:ptb1:code tracked in lab46 semester repo [13/13] |
|
| 214 | +``` |
|
| 215 | + |
|
| 216 | +### Additionally |
|
| 217 | + |
|
| 218 | + * Solutions not abiding by spirit of project will be subject to a 50% overall deduction |
|
| 219 | + * Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction |
|
| 220 | + * 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 |
|
| 221 | + * 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 |