User Tools

Site Tools


haas:fall2020:common:projects:clr0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
haas:fall2020:common:projects:clr0 [2020/10/09 14:50] wedgehaas:fall2020:common:projects:clr0 [2020/10/09 19:49] (current) – [Input and Output via the GPIO pins on the pi] wedge
Line 18: Line 18:
 ALSO: read through Chapter 5 in the [[https://lab46.g7n.org/downloads/tutorial.pdf|FreeNove Tutorial]] ALSO: read through Chapter 5 in the [[https://lab46.g7n.org/downloads/tutorial.pdf|FreeNove Tutorial]]
  
 +AND: the wiringPi API on [[http://wiringpi.com/reference/software-pwm-library/|Sofware PWM functionality]]
 =====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 multiple LEDs and a button to your breadboard and witnessing your ability to access and control them via software.+For this project, you will be working with a C program using the wiringPi library on the Raspberry Pi, wiring up a circuit containing an RGB LED to your breadboard and witnessing your ability to access and control it in varying states of on and off (more than just simply "ON" and "OFF"via software-based Pulse Width Modulation (PWM) scheme.
  
 =====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:~/src/desig/iwb2$ gpio readall+yourpi:~/src/desig/clr0$ gpio readall
  +-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+  +-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+
  | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |  | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
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", which when lit, indicates the device is powered on, among many, MANY, **MANY** other applications. 
- 
-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't remain in the changed state- once we release it, like a keyboard key, it reverts to its default state). 
- 
-For this endeavour, you will need to obtain the following items out of the electronics kit you obtained for the class: 
- 
-{{ :haas:fall2020:common:projects:iwb2partslist1.png |}} 
- 
-{{ :haas:fall2020:common:projects:iwb2partslist2.png |}} 
-=====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: 
- 
-{{ :haas:fall2020:common:projects:ledbarcircuit.png |}} 
- 
-And an isolated button circuit: 
- 
-{{ :haas:fall2020:common:projects:iwb2circuit.png |}} 
- 
-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, and then integrate both into the same super-circuit. 
- 
-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> 
- 
-<WRAP round info>Before you seek to actually test your circuit, please get verification to proceed from the class channel on discord by posting a clear picture of everything (a focus on a clear view of the wires, and where they plug into the breadboard). There are MANY parts, and especially as we have our first exposure, it is best to insert as many quality control checks as possible to ensure the greatest chances of mistakes are mitigated.</WRAP> 
- 
-=====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:~/src/desig$ grabit desig iwb2 +lab46:~/src/desig$ grabit desig clr0 
-make: Entering directory '/var/public/SEMESTER/desig/iwb2+make: Entering directory '/var/public/SEMESTER/desig/clr0
-'/var/public/SEMESTER/desig/iwb2/Makefile' -> '/home/user/src/desig/iwb2/Makefile' +'/var/public/SEMESTER/desig/clr0/Makefile' -> '/home/user/src/desig/clr0/Makefile' 
-'/var/public/SEMESTER/desig/iwb2/iwb2.c' -> '/home/user/src/desig/iwb2/iwb2.c' +'/var/public/SEMESTER/desig/clr0/clr0.c' -> '/home/user/src/desig/clr0/clr0.c' 
-make: Leaving directory '/var/public/SEMESTER/desig/iwb2'+make: Leaving directory '/var/public/SEMESTER/desig/clr0'
 lab46:~/src/desig$  lab46:~/src/desig$ 
 </cli> </cli>
  
-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 and verifying operation of your properly hooked up electronics circuitWhen donesubmit it on lab46.+Please reference the [[https://lab46.g7n.org/downloads/tutorial.pdf|FreeNove Tutorial]], Chapter 5, Project 5.1 for the parts and circuit diagram.  
 + 
 +=====Program===== 
 +It is your task to obtain, study, and complete a program (clr0.c) that will pseudorandomly set the RGB LED to different coloursonce per second. Most of the code has been provided for you, you must complete the part as indicated in the comments.
  
-To utilize the needed functionality for this projectyou will need to ensure you have the following packages installed:+  * Retain the structure of the grabit code for your submission to be evaluated (do NOT use any added functions). 
 +  * Retain the variables of the grabit codeas named, in your submission to be evaluated. 
 +  * From the FreeNove tutorial or the wiringPi API on sofware PWM functionality, determine how to set the obtained red/green/blue values to the appropriate pins on your RGB LED, so that it will light up with those colour values (and change, each second the program is running, to a different value). 
 +  * Update your clr0.c program to perform this action to complete it. 
 +  * do NOT remove the delay. You may shorten (no shorter than 500mS, please) or lengthen the delay, but do not remove it entirely.
  
-  * **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 in success.
-  * **wiringpi** (hopefully you took care of this in led0)+
  
 =====Compiling===== =====Compiling=====
haas/fall2020/common/projects/clr0.1602255018.txt.gz · Last modified: 2020/10/09 14:50 by wedge