haas/fall2026/c4eng/projects/stl1.md
... ...
@@ -0,0 +1,183 @@
1
+# ENGR1050 C for Engineers
2
+
3
+# PROJECT: Seeing The Light (STL1)
4
+
5
+## OBJECTIVE
6
+
7
+We continue our explorations of the electronics kit, by adding additional
8
+LEDs to control them in unison with a C program on our pi, having them
9
+count in binary.
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
+## TASK
22
+
23
+After exploring, assembling, and testing the intended circuit (4 LEDs),
24
+adapt the provided C code to use the bank of connected LEDs to count in
25
+binary from 0000 to 1111 (0 to 15).
26
+
27
+Creating a variable, and using its value as a count, your task is to make
28
+use of **if** statements and **bitwise logic** to determine from an
29
+ongoing count the state of the individual bits.
30
+
31
+It is your task to write a C program that interfaces successfully with
32
+four independently connected LED circuits, arranged in some orientation
33
+to ascertain an order or positioning, where your program will (in endless
34
+fashion, or until being manually interrupted/powered down) display a
35
+count (in binary) of values from 0 to 15 (then rollover, or reset).
36
+
37
+For the example below, a "1" means the LED in that position is `ON`, and
38
+a "0" means the LED in that position is `OFF`, you will want to write a
39
+program that performs the following progression (over and over again):
40
+
41
+```
42
+0 0 0 0
43
+0 0 0 1
44
+0 0 1 0
45
+0 0 1 1
46
+0 1 0 0
47
+0 1 0 1
48
+0 1 1 0
49
+0 1 1 1
50
+1 0 0 0
51
+1 0 0 1
52
+1 0 1 0
53
+1 0 1 1
54
+1 1 0 0
55
+1 1 0 1
56
+1 1 1 0
57
+1 1 1 1 <-- 15, the maximum value to display
58
+0 0 0 0 <-- 0, we "roll over" and start again
59
+0 0 0 1
60
+0 0 1 0
61
+...
62
+```
63
+
64
+![LED circuit](images/stl0_circuit.jpg)
65
+
66
+The circuits you will be constructing will be the same ones we previously
67
+built in class- an LED circuit receiving power (from a GPIO pin), having
68
+a 220 Ohm resistor, an LED, and then connecting to ground.
69
+
70
+We will be powering each LED circuit from a unique GPIO pin, allowing for
71
+conditional supply of power, based on our code.
72
+
73
+## OPERATING THE PROJECT
74
+
75
+These projects will have two paths to them, depending on which device you
76
+are using:
77
+
78
+ * Raspberry Pi single board computer (4/5) using the `wiringPi` library
79
+ * Raspberry Pi Pico microcontroller
80
+
81
+```
82
+lab46:~/SEMESTER/c4eng/stl1$ make
83
+Please select which development environment:
84
+
85
+ make wiringpi - using the Raspberr Pi with wiringpi library
86
+ make pico - using the Raspberry Pi pico
87
+
88
+after which, you can use 'make' to build
89
+lab46:~/SEMESTER/c4eng/stl1$
90
+```
91
+
92
+Run the `make` command with the category representing the path you will
93
+be working with for this project.
94
+
95
+After which, if you do an `ls`, you will see a cyan-colored file called
96
+`stl1.c`. This is the C file you will be editing for this project.
97
+
98
+Go ahead and view it, study the code, eventually make any changes, save
99
+and return to the command-line.
100
+
101
+To build it, you simply run: `make`
102
+
103
+If there are no errors, it will build, and you proceed from there.
104
+
105
+## EXECUTION
106
+
107
+If on the pico, follow the process for downloading the binary file and
108
+programming your pico.
109
+
110
+If on the full Raspberry Pi, you have a green executable you can run just
111
+as we've done in our other projects.
112
+
113
+## STRATEGY
114
+
115
+The general flow of the process (one way of going about it, anyway) can
116
+be described as follows:
117
+
118
+```
119
+SET COUNTER TO ZERO
120
+LOOP:
121
+ SHOULD THE ONE'S POSITION HAVE A ONE:
122
+ ACTIVATE THE ONE'S PLACE
123
+ OTHERWISE:
124
+ DEACTIVATE THE ONE'S PLACE
125
+
126
+ SHOULD THE TWO'S POSITION HAVE A ONE:
127
+ ACTIVATE THE TWO'S PLACE
128
+ OTHERWISE:
129
+ DEACTIVATE THE TWO'S PLACE
130
+
131
+ SHOULD THE FOUR'S POSITION HAVE A ONE:
132
+ ACTIVATE THE FOUR'S PLACE
133
+ OTHERWISE:
134
+ DEACTIVATE THE FOUR'S PLACE
135
+
136
+ SHOULD THE EIGHT'S POSITION HAVE A ONE:
137
+ ACTIVATE THE EIGHT'S PLACE
138
+ OTHERWISE:
139
+ DEACTIVATE THE EIGHT'S PLACE
140
+
141
+ PAUSE FOR HUMAN PERCEPTION
142
+
143
+ LET THE COUNTER BE INCREMENTED BY ONE
144
+
145
+ REPEAT THE LOOP
146
+```
147
+
148
+## SUBMISSION
149
+
150
+To successfully complete this project, the following criteria must be
151
+met:
152
+
153
+ * Code must compile/execute cleanly (no notes, warnings, nor errors)
154
+ * Code must be nicely and consistently indented
155
+ * Code must be well commented
156
+ * Do NOT double space your code. Group like statements together.
157
+ * Track/version the source code in your private semester repository
158
+
159
+To submit this project to me, make sure the `Makefile` and your completed
160
+`stl1.c` file are placed in your private semester repository under
161
+`c4eng/stl1/`
162
+
163
+What I'll be looking for:
164
+
165
+### RUBRIC
166
+
167
+I'll be evaluating the project based on the following criteria:
168
+
169
+```
170
+156:stl1:final tally of results (156/156)
171
+*:stl1:post a picture or short video to the DISCORD [26/26]
172
+*:stl1:code compiles without errors [26/26]
173
+*:stl1:code makes use of if statements [26/26]
174
+*:stl1:code makes use of bitwise logic [26/26]
175
+*:stl1:program conforms to project specifications [26/26]
176
+*:stl1:code tracked in private semester repo [26/26]
177
+```
178
+
179
+Additionally:
180
+ * Solutions not abiding by spirit of project will be subject to a 50% overall deduction
181
+ * Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
182
+ * 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
183
+ * 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