ENGR1050 C for Engineers
PROJECT: Seeing The Light (STL1)
OBJECTIVE
We continue our explorations of the electronics kit, by adding additional LEDs to control them in unison with a C program on our pi, having them count in binary.
OBTAIN THE PROJECT FILES
To assist with consistency across all implementations, data files for use
with this project are available on lab46 as a grabit, or within the
class repository under the projects/ directory. Please copy the data to
your project directory in your private semester repository to begin work.
Please study any provided code or supporting documents, and look up, experiment, and ask questions on aspects that you do not understand.
TASK
After exploring, assembling, and testing the intended circuit (4 LEDs), adapt the provided C code to use the bank of connected LEDs to count in binary from 0000 to 1111 (0 to 15).
Creating a variable, and using its value as a count, your task is to make use of if statements and bitwise logic to determine from an ongoing count the state of the individual bits.
It is your task to write a C program that interfaces successfully with four independently connected LED circuits, arranged in some orientation to ascertain an order or positioning, where your program will (in endless fashion, or until being manually interrupted/powered down) display a count (in binary) of values from 0 to 15 (then rollover, or reset).
For the example below, a "1" means the LED in that position is ON, and
a "0" means the LED in that position is OFF, you will want to write a
program that performs the following progression (over and over again):
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1 <-- 15, the maximum value to display
0 0 0 0 <-- 0, we "roll over" and start again
0 0 0 1
0 0 1 0
...

The circuits you will be constructing will be the same ones we previously built in class- an LED circuit receiving power (from a GPIO pin), having a 220 Ohm resistor, an LED, and then connecting to ground.
We will be powering each LED circuit from a unique GPIO pin, allowing for conditional supply of power, based on our code.
OPERATING THE PROJECT
These projects will have two paths to them, depending on which device you are using:
- Raspberry Pi single board computer (4/5) using the
wiringPilibrary - Raspberry Pi Pico microcontroller
lab46:~/SEMESTER/c4eng/stl1$ make
Please select which development environment:
make wiringpi - using the Raspberr Pi with wiringpi library
make pico - using the Raspberry Pi pico
after which, you can use 'make' to build
lab46:~/SEMESTER/c4eng/stl1$
Run the make command with the category representing the path you will
be working with for this project.
After which, if you do an ls, you will see a cyan-colored file called
stl1.c. This is the C file you will be editing for this project.
Go ahead and view it, study the code, eventually make any changes, save and return to the command-line.
To build it, you simply run: make
If there are no errors, it will build, and you proceed from there.
EXECUTION
If on the pico, follow the process for downloading the binary file and programming your pico.
If on the full Raspberry Pi, you have a green executable you can run just as we've done in our other projects.
STRATEGY
The general flow of the process (one way of going about it, anyway) can be described as follows:
SET COUNTER TO ZERO
LOOP:
SHOULD THE ONE'S POSITION HAVE A ONE:
ACTIVATE THE ONE'S PLACE
OTHERWISE:
DEACTIVATE THE ONE'S PLACE
SHOULD THE TWO'S POSITION HAVE A ONE:
ACTIVATE THE TWO'S PLACE
OTHERWISE:
DEACTIVATE THE TWO'S PLACE
SHOULD THE FOUR'S POSITION HAVE A ONE:
ACTIVATE THE FOUR'S PLACE
OTHERWISE:
DEACTIVATE THE FOUR'S PLACE
SHOULD THE EIGHT'S POSITION HAVE A ONE:
ACTIVATE THE EIGHT'S PLACE
OTHERWISE:
DEACTIVATE THE EIGHT'S PLACE
PAUSE FOR HUMAN PERCEPTION
LET THE COUNTER BE INCREMENTED BY ONE
REPEAT THE LOOP
SUBMISSION
To successfully complete this project, the following criteria must be met:
- Code must compile/execute cleanly (no notes, warnings, nor errors)
- Code must be nicely and consistently indented
- Code must be well commented
- Do NOT double space your code. Group like statements together.
- Track/version the source code in your private semester repository
To submit this project to me, make sure the Makefile and your completed
stl1.c file are placed in your private semester repository under
c4eng/stl1/
What I'll be looking for:
RUBRIC
I'll be evaluating the project based on the following criteria:
156:stl1:final tally of results (156/156)
*:stl1:post a picture or short video to the DISCORD [26/26]
*:stl1:code compiles without errors [26/26]
*:stl1:code makes use of if statements [26/26]
*:stl1:code makes use of bitwise logic [26/26]
*:stl1:program conforms to project specifications [26/26]
*:stl1:code tracked in private semester repo [26/26]
Additionally:
- Solutions not abiding by spirit of project will be subject to a 50% overall deduction
- Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
- 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
- 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