Thursday, March 30, 2017

Day 4

Day 4


Implementing two LED's using two buttons.


The desired effect, the Po-Po lights lol.


Now using an RGB LED. each wire here was color coded so that the red and green LED pins can be easily verified.


Practicing using and (&&) statements.


Here we practice using bam (!,not) and or (||) statements.


Box analysis for figuring out what the code will do at each of the scenarios.


Here there are four scenarios at which the code can go through.


The LED lights up red here. The golf ball is used to make the light look bigger but it seems to make it dimmer too.


The LED here lights green.


The LED lights blue.


Now by combining red and blue in the RGB digital write commands, we see purple.


3 other codes with their own scenarios.


This code seems to have many branches within branches.


Switch Crank's case rank code.

Homework

1. If a1 is true and a2 is false, then which of the following expressions are true?

(a) a1 && a2 False
(b) a1 || a2 True
(c) !(a1 || a2) True
(d) !a1 && a2 True

2. Give the value of, a, after the following set of statements, is executed.

int a = 750;
...
if (a>0)
if (a >= 1000)
a = 0;
else
if (a < 500)
a *= 2;
else
a *= 10;
else
a += 3;

3. Modify your RGB night light as follows: 

(a) Modify your program to add the colors of Teal, Orange, and White.

(b) Implement a switch statement to control the color mode.

(c) Add additional buttons to independently control each of the three colors.

(d) Add a blink mode to have your color flash on and off.



No comments:

Post a Comment