This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
haas:fall2020:common:projects:clr0 [2020/10/09 14:41] – created wedge | haas:fall2020:common:projects:clr0 [2020/10/09 19:49] (current) – [Input and Output via the GPIO pins on the pi] wedge | ||
---|---|---|---|
Line 1: | Line 1: | ||
======PROJECT====== | ======PROJECT====== | ||
- | PROJECT: | + | PROJECT: |
=====Objective===== | =====Objective===== | ||
- | In the ledX electronics | + | A mild throwback to the ledX projects, |
- | + | ||
- | Here we put it all together: maximal button and LED goodness! | + | |
=====Abstraction===== | =====Abstraction===== | ||
Line 14: | Line 12: | ||
=====Reading===== | =====Reading===== | ||
- | Please be sure to familiarize yourself with the following content in " | + | In "The C Book", please read through Chapter 8. |
+ | |||
+ | Review needed concepts in [[https://www.tutorialspoint.com/cprogramming/|this tutorial]] and also [[https:// | ||
- | * [[https://publications.gbdirect.co.uk//c_book/ | + | ALSO: read through Chapter 5 in the [[https://lab46.g7n.org/downloads/tutorial.pdf|FreeNove Tutorial]] |
+ | AND: the wiringPi API on [[http:// | ||
=====Background===== | =====Background===== | ||
- | For this project, you will be working with a C program using the wiringPi library on the Raspberry Pi, wiring up a circuit containing | + | For this project, you will be working with a C program using the wiringPi library on the Raspberry Pi, wiring up a circuit containing |
=====Input and Output via the GPIO pins on the pi===== | =====Input and Output via the GPIO pins on the pi===== | ||
Line 33: | Line 34: | ||
<cli> | <cli> | ||
- | yourpi: | + | yourpi: |
| | ||
| BCM | wPi | | | BCM | wPi | | ||
Line 79: | Line 80: | ||
It may seem a bit bewildering or overwhelming at first, but like anything, time and exposure will ensure it becomes increasingly second nature. | It may seem a bit bewildering or overwhelming at first, but like anything, time and exposure will ensure it becomes increasingly second nature. | ||
- | |||
- | =====Wiring up our circuit===== | ||
- | This circuit is basically an enhancement upon the one you made for the led1 project. So the parts needed has some similar items, but also some new ones. | ||
- | |||
- | In this project, we will be hooking up two different peripherals to some of our Raspberry Pi pins: a set of light emitting diodes (LED) and a button, and then proceed to interface with them to access and control their state (of being ON or OFF). | ||
- | |||
- | You have likely encountered LEDs endlessly in your everyday life: commonly used as a "power light", | ||
- | |||
- | You have also encountered buttons seemingly in just as ubiquitous a fashion: a button is essentially a switch, toggling something ON or OFF. A light switch is a prime example of this (although in our case, our button doesn' | ||
- | |||
- | For this endeavour, you will need to obtain the following items out of the electronics kit you obtained for the class: | ||
- | |||
- | {{ : | ||
- | |||
- | {{ : | ||
- | =====The Circuit to Construct===== | ||
- | With those components, you will want to place them onto your breadboard, in a manner similar to previous week's circuits (namely, a combination of led2 and iwb1), but obviously with something different going on. | ||
- | |||
- | Of particular note: we are going to create circuit involving TWO buttons, and the LEDbar we last used in the led2 project. Each button will perform a unique function, impacting what gets displayed on the LEDbar. | ||
- | |||
- | Included here again is the **led2** circuit, for reference: | ||
- | |||
- | {{ : | ||
- | |||
- | And an isolated button circuit: | ||
- | |||
- | {{ : | ||
- | |||
- | You want to COMBINE the two circuits, without any overlap or conflicted use of GPIO pins. The idea is for you to study the two circuits in isolation, develop an understanding, | ||
- | |||
- | Take note of how everything is being plugged in, and what connection on the T-cobbler is being utilized. | ||
- | |||
- | <WRAP round info>Pay attention to the color bands of the resistors! We are using two different kinds on this project, and mixing them up will result in erratic or nonfunctional results!</ | ||
- | |||
- | <WRAP round info> | ||
- | |||
- | =====Program===== | ||
- | It is your task to implement a program (iwb2.c) that accepts input from the buttons, and outputs to the LEDbar, in accordance with the following: | ||
- | |||
- | * the LEDbar displays a 10-bit binary number (there exists code in previous projects that accomplishes this task | ||
- | * ONE of the two buttons is an INCREMENT operation. By pressing it, your program needs to recognize it is pressed, and increment the number being displayed by 1 (per update) | ||
- | * the OTHER of the two buttons is a DECREMENT operation. By pressing it, your program needs to recognize it is pressed, and decrement the number being displayed by 1 (per update) | ||
- | |||
- | * some things of note: | ||
- | * each LED connected to a unique GPIO line | ||
- | * each BUTTON connected to a unique GPIO line | ||
- | * do NOT remove the delay. You may shorten (no shorter than 50mS) or lengthen the delay, but do not remove it entirely. | ||
====Grabbing project resources (on lab46)==== | ====Grabbing project resources (on lab46)==== | ||
Line 131: | Line 85: | ||
<cli> | <cli> | ||
- | lab46: | + | lab46: |
- | make: Entering directory '/ | + | make: Entering directory '/ |
- | '/ | + | '/ |
- | '/ | + | '/ |
- | make: Leaving directory '/ | + | make: Leaving directory '/ |
lab46: | lab46: | ||
</ | </ | ||
- | At which point you can change into the newly created and populated **iwb2/** directory. | + | At which point you can change into the newly created and populated **clr0/** directory. |
====Getting project resources from lab46 to your pi==== | ====Getting project resources from lab46 to your pi==== | ||
Line 150: | Line 104: | ||
Then, over on your pi, use **hg** to **pull** and **update** the new changes into place. Then you can proceed. | Then, over on your pi, use **hg** to **pull** and **update** the new changes into place. Then you can proceed. | ||
- | ====On your pi==== | + | =====Wiring up our circuit===== |
- | Study and run this program on your pi in conjunction with testing | + | Please reference the [[https:// |
+ | |||
+ | =====Program===== | ||
+ | It is your task to obtain, study, | ||
- | To utilize | + | * Retain |
+ | * Retain the variables of the grabit code, as named, in your submission to be evaluated. | ||
+ | * From the FreeNove tutorial or the wiringPi API on sofware PWM functionality, | ||
+ | * Update your clr0.c program to perform this action to complete it. | ||
+ | * do NOT remove | ||
- | * **build-essential** (hopefully you took care of this in ntr0) | + | NOTE: There may be functionally equivalent code in the resources for this project. You are not to copy and paste it, but instead to identify the needed functionality and translate it into a form compatible with the grabit program provided for this project. Failure to do so will not result |
- | * **wiringpi** (hopefully you took care of this in led0) | + | |
=====Compiling===== | =====Compiling===== |