Corning Community College
ENGR1050 C for Engineers
We commence on our exploration of the electronics kit, by creating and controlling an LED with a C program on our pi.
Do note, the productive way to go about this project involves taking the following steps:
If you start too late, and do not ask questions, and do not have enough time and don't know what is going on, you are not doing the project correctly.
After exploring, assembling, and testing the intended circuit, adapt the provided C code to blink the LED on the circuit, cycling on/off at least once every second.
To assist with consistency across all implementations, data files for use with this project are available on lab46 via the grabit tool. Be sure to obtain it and ensure your implementation properly works with the provided data.
lab46:~/src/SEMESTER/DESIG$ grabit DESIG PROJECT
You will want to go here to edit and fill in the various sections of the document:
yourpi:~$ wget https://project-downloads.drogon.net/wiringpi-latest.deb
NOTE: domain say “dr-OH-gon”, it does NOT say “dragon”
yourpi:~$ sudo dpkg -i wiringpi-latest.deb
Since you can't make and run the program on lab 46, you will need to add, commit, and push it onto your repository with the hg commands, so that you can pull it onto your pi. Once you've successflly pushed everything onto the repository, go to your pi and use this command to pull it back:
hg pull;hg update
Once you've done that, you should be able to cd into the stl0 directory, where you can compile and run your program with the make and ./stl0 commands. If your breadboard is set up, and the stl0.c file is being applied to the right pin #, you might notice a change in the LED.
“gpio readall” will open up a table showing the physical pin layout of your pi. It will also tell you whether a pin is set to input or output, and whether the pin is turned on or off (V=0 shows the pin is off, v=1 shows the pin is on).
“gpio mode WIRINGPI_PIN# MODE” will change the mode of the designated pin. You must use the WiringPi pin number. Mode can either be in (input) or out (output).
“gpio write WIRINGPI_PIN# STATE” will change the ON/OFF state of a pin. 0=off and 1=on
Voltage is the electric potential between two points. Volts is the SI unit used for voltage. Voltage is often described as the “pressure” that pushes electricity. An analogy often used to describe the relationship between voltage, amperage, and resistance, is water in a hose. Voltage can be imagined as the water pressure, amperage can be imagined as the flow rate, and resistance is imagined as the thickness of the hose.
For circuit projects using a breadboard and Raspberry Pi, the typical voltages are 3.3V and 5V.
Input on any of the Raspberry Pi's GPIO pins should not be 5V. The Raspberry Pi is not 5V tolerant. This is confusing, as there are pins to output 5V, which is used to power external components.
The ground “pin” is extremely important if connecting a circuit together. If done without a ground you can easily fry your breadboard or even kill an L.E.D light. Your ground pins are indicated by a GND next to the designated pin. For every power source connection, you must have a ground wire going to one of the Negative column.
Amperage is a measure of the magnitude of electrical current.
Resistance, or electrical resistance, is a measure of how difficult it is for current to flow. Resistance is measured in the SI unit Ohms. Resistors are components for implementing electrical resistance in a circuit. Resistance is equivalent to V/I, where V is voltage and I is current, derived from V=I*R.
A resistor is a component that slows down the flow of electrons through an electrical circuit. The specified resistance value can be decoded by looking at the coloured bands that surround the body of the resistor.
A breadboard is a tool used for prototyping circuits without the need for soldering components onto a board. They typically come with detachable rails on the side, usually used (and marked) for power and ground. These red and blue marked strips are connected along the entire length of the columns. This allows you to power and ground multiple components easily.
Between these detachable rails are rows of 5 connected notches on either side of the divot in the middle. The 5 notches in each row are connected, allowing you to form circuits between attached components.
GPIO.0 is actually GPIO17 on your T-cobbler
To discover this, you can use the command
gpio redall
This will bring up a table of all the pins on the t-cobbler. On your t-cobbler, you will count the pins left to right starting at one, until you get to the pin you are using. Then, you will find the number your pin is at, then use the list to line it up with the wpi name. The Wpi name is the one we will be referring to whenever we need to write or indicate a pin in our code
Brief Definition:
A light-emitting diode (LED) is a semiconductor device that emits light when current flows through it.
Light-emitting diodes only allow electrical current to pass through them one way. The longer lead is the positive connection, and the shorter lead is the negative connection.
A resistor is a component for implementing electrical resistance in a circuit. This is useful for lowering the flow of current across a circuit. By applying a resistor to a circuit with an LED, you could prevent the LED from burning out, or simply make it dimmer without needing to adjust voltage. Resistors have color coded bands on the body of them to indicate resistance in Ohms. For instance, 3 bands that are orange, orange, red, indicates a 330 Ohm resistor. The color coding is defined in the international standard IEC 60062.
To be successful in this project, the following criteria (or their equivalent) must be met:
Let's say you have completed work on the project, and are ready to submit, you would do the following (assuming you have a program called uom0.c):
lab46:~/src/SEMESTER/DESIG/PROJECT$ make submit
You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.
I'll be evaluating the project based on the following criteria:
39:stl0:final tally of results (39/39) *:stl0:used grabit to obtain project by the Sunday prior to duedate [6/6] *:stl0:clean compile, no compiler messages [7/7] *:stl0:program conforms to project specifications [20/20] *:stl0:code tracked in lab46 semester repo [6/6]