User Tools

Site Tools


haas:fall2020:common:projects:clr2

Differences

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

Link to this comparison view

Next revision
Previous revision
haas:fall2020:common:projects:clr2 [2020/10/10 12:22] – created wedgehaas:fall2020:common:projects:clr2 [2020/11/04 12:51] (current) – [Wiring up our circuit] wedge
Line 1: Line 1:
 ======PROJECT====== ======PROJECT======
-PROJECT: Colored LED Research (clr1)+PROJECT: Colored LED Research (clr2)
  
 =====Objective===== =====Objective=====
-A mild throwback to the ledX projects, where we find ourselves once again playing with an LED, only an LED of MANY colours: the RGB LED! We will be eliciting additional effects from the RGB LED in this project.+A mild throwback to the ledX projects, where we find ourselves once again playing with an LED, only an LED of MANY colours: the RGB LED!
  
 +We will be integrating buttons and a switch to allow finer, manual control over the individual red, green, blue values of the LED.
 =====Abstraction===== =====Abstraction=====
 {{page>haas:fall2020:common:projects:abstraction&noheader}} {{page>haas:fall2020:common:projects:abstraction&noheader}}
Line 23: Line 24:
 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 a software-based Pulse Width Modulation (PWM) scheme. 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 a software-based Pulse Width Modulation (PWM) scheme.
  
 +With the help of buttons and a switch, we will be able to allow the user to manually adjust the individual red, green, and blue values of the RGB LED,
 =====Loops===== =====Loops=====
 {{page>haas:fall2020:common:projects:loops&noheader}} {{page>haas:fall2020:common:projects:loops&noheader}}
Line 89: Line 91:
  
 <cli> <cli>
-lab46:~/src/desig$ grabit desig clr1 +lab46:~/src/desig$ grabit desig clr2 
-make: Entering directory '/var/public/SEMESTER/desig/clr1+make: Entering directory '/var/public/SEMESTER/desig/clr2
-'/var/public/SEMESTER/desig/clr1/Makefile' -> '/home/user/src/desig/clr1/Makefile' +'/var/public/SEMESTER/desig/clr2/Makefile' -> '/home/user/src/desig/clr2/Makefile' 
-'/var/public/SEMESTER/desig/clr1/clr1.c' -> '/home/user/src/desig/clr1/clr1.c' +'/var/public/SEMESTER/desig/clr2/clr2.c' -> '/home/user/src/desig/clr2/clr2.c' 
-make: Leaving directory '/var/public/SEMESTER/desig/clr1'+make: Leaving directory '/var/public/SEMESTER/desig/clr2'
 lab46:~/src/desig$  lab46:~/src/desig$ 
 </cli> </cli>
  
-At which point you can change into the newly created and populated **clr1/** directory.+At which point you can change into the newly created and populated **clr2/** directory.
  
 ====Getting project resources from lab46 to your pi==== ====Getting project resources from lab46 to your pi====
Line 113: Line 115:
 The RGB LED circuit for this project remains identical to that of clr0 and clr1. New will be the buttons and switch circuits that are added. The RGB LED circuit for this project remains identical to that of clr0 and clr1. New will be the buttons and switch circuits that are added.
  
 +You will want to add THREE button circuits, each connected to a unique GPIO. You can utilize the plastic button caps to help identify which button is which. Each button will be directly responsible for adjusting the current level of colour intensity (ie pressing the button intended to adjust the red component of the RGB LED will adjust the red value).
 +
 +You will also want to utilize a switch, which looks like this:
 +
 +{{ :haas:fall2020:common:projects:switch.png |}}
 +
 +Your kit should have come with two of them, you will need ONE.
 +
 +The switch circuit will involve hooking up 3.3v to the center pin, putting a 1k resistor between the pin of the switch and the 3.3v source coming from the pi. And ONE of the other pins should then go through a 10k resistor into a GPIO pin on the pi (set to INPUT mode, just like the buttons).
 +
 +This switch is going to control the DIRECTION of change- one way, it will be INCREASING in value. The other, it will be DECREASING.
 +
 +So, your ultimate circuit will have FOUR independent inputs- red control, green control, and blue control (all buttons), and then the DIRECTION switch (increase/decrease). FOUR GPIOs in INPUT mode are needed.
 +
 +====Final result====
 +Once all connected, your circuit should allow for directional, per-colour adjustment of each of the three colours. Here's an animated gif of one such circuit in action:
 +
 +{{ :haas:fall2020:common:projects:clr2_working_example.gif |}}
 =====Program===== =====Program=====
-It is your task to obtainstudy, and complete a program (clr2.c) that is to explore and display the gradual changing of color componentsin isolation and combinations. You must complete the parts as indicated in the comments to the actions described.+Your program to implement for this project involves using the wired up RGB LEDthe three buttons, and the switch, to do the following:
  
 +  * switch control direction of adjustment (increasing in value or decreasing in value)
 +  * each button allows you to adjust the value of a particular colour component of the RGB LED. It is recommended that you use the button caps of the respective colour (put the red cap on the red adjustment button, for instance)
 +  * display the current RGB values on the RGB LED.
 +  * please have some sort of minimal delay in your program... no shorter than 100mS
 =====Compiling===== =====Compiling=====
 Since the grabit brought in a Makefile, you can compile your code simply by typing: **make** Since the grabit brought in a Makefile, you can compile your code simply by typing: **make**
Line 127: Line 151:
 When done and ready to submit, on lab46: **make submit** When done and ready to submit, on lab46: **make submit**
  
 +=====Strategy=====
 +In general, you will want your completed program to perform in the manner described as follows (in English-like pseudocode):
 +
 +<code>
 +LOOP TO KEEP PROGRAM GOING
 +
 +        IF SWITCH IS IN POSITION 1:
 +                DIR <- +10
 +        ELSE
 +                DIR <- -10
 +        END IF
 +
 +        IF RED BUTTON IS PRESSED:
 +                REDCOLOR <- REDCOLOR + DIR
 +        END IF
 +
 +        IF GREEN BUTTON IS PRESSED:
 +                GREENCOLOR <- GREENCOLOR + DIR
 +        END IF
 +
 +        IF BLUE BUTTON IS PRESSED:
 +                BLUECOLOR <- BLUECOLOR + DIR
 +        END IF
 +
 +        SETRED(REDCOLOR)
 +        SETGREEN(GREENCOLOR)
 +        SETBLUE(BLUECOLOR)
 +
 +        DELAY
 +
 +END LOOP
 +</code>
 =====Submission===== =====Submission=====
 To successfully complete this project, the following criteria must be met: To successfully complete this project, the following criteria must be met:
Line 156: Line 212:
 <code> <code>
 91:clr2:final tally of results (91/91) 91:clr2:final tally of results (91/91)
-*:clr2:post picture of program-powered LED in layout to #desig [13/13] +*:clr2:post picture of unpowered layout to #desig and get approval [13/13] 
 +*:clr2:post picture to #desig by Sunday before deadline [13/13] 
 +*:clr2:post picture of powered layout to #desig [13/13] 
 *:clr2:grabit on the code on lab46 by Sunday before deadline [13/13] *:clr2:grabit on the code on lab46 by Sunday before deadline [13/13]
 *:clr2:clr2.c code adequately modified per project requirements [26/26] *:clr2:clr2.c code adequately modified per project requirements [26/26]
-*:clr2:colors are appropriately reset prior to each section [13/13] 
-*:clr2:color levels adjust in offsets of 10, with useful delays [13/13] 
 *:clr2:updated code is pushed to lab46 repository [13/13] *:clr2:updated code is pushed to lab46 repository [13/13]
 </code> </code>
haas/fall2020/common/projects/clr2.1602332544.txt.gz · Last modified: 2020/10/10 12:22 by wedge