Week 3: RGB and Multi LEDs

Just another week of me pretending like I have this discovery thing down and I definitely do not. I will say that this blog is a good record of progress though. And how one has to learn through a lot of errors. What was it, like nearly 20 inventors and six plus decades before Edison finally got a successful light bulb down? So week three and this kind of progress isn't too bad.

 In this week's challenges we wer to complete two tasks: get an RGB LED light working and changing and to get multiple LEDs lit. 

1. RGB LED - get the light flashing, change the speed, change the colors, change brightness, etc. 

Below are my boards:


My sketch:


Video of my board "working":


Code I used (note: THIS is the area I have come to realize I am messing up in. So the likelihood of this being wrong is nearly guaranteed) :

// Define Pins

#define BLUE 11

#define GREEN 10

#define RED 9

 

void setup()

{

pinMode(RED, OUTPUT);

pinMode(GREEN, OUTPUT);

pinMode(BLUE, OUTPUT);

digitalWrite(RED, HIGH);

digitalWrite(GREEN, LOW);

digitalWrite(BLUE, LOW);

}

 // define variables

int redValue;

int greenValue;

int blueValue;

 // main loop

void loop()

{

#define delayTime 5 // fading time between colors

redValue = 0; // choose a value between 1 and 255 to change the color.

greenValue = 15;

blueValue = 0;

 for(int i = 0; i < 255; i += 1) // fades out red bring green full when i=255

{

redValue -= 1;

greenValue += 1;

analogWrite(RED, redValue);

analogWrite(GREEN, greenValue);

delay(delayTime);

}

redValue = 0;

greenValue = 255;

blueValue = 0;

for(int i = 0; i < 255; i += 1) // fades out green bring blue full when i=255

{

greenValue -= 1;

blueValue += 1;

analogWrite(GREEN, greenValue);

analogWrite(BLUE, blueValue);

delay(delayTime);

}

 redValue = 0;

greenValue = 0;

blueValue = 255;

 for(int i = 0; i < 255; i += 1) // fades out blue bring red full when i=255

{

blueValue -= 1;

redValue += 1;

analogWrite(BLUE, blueValue);

analogWrite(RED, redValue);

delay(delayTime);

}

2. Multiple LEDs - flashing, change lights, pattern or mode in which lights flash/move

Here is my board setup: 


Here is a sketch of my board: 


Here is a video of my board "working" (excuse the maniacal snicker that you might possibly hear. it was out of utter disbelief I got the board doing something that I was pretty sure not right):

Code I used  (note: THIS is the area I have come to realize I am messing up in. So the likelihood of this being wrong is nearly guaranteed):

int ledPin = 8;

int buttonApin = 9;

int buttonBpin = 8;

 byte leds = 0;

 void setup() 

{

  pinMode(ledPin, OUTPUT);

  pinMode(buttonApin, INPUT_PULLUP);  

  pinMode(buttonBpin, INPUT_PULLUP);  

}

 void loop() 

{

  if (digitalRead(buttonApin) == LOW)

  {

    digitalWrite(ledPin, HIGH);

  }

  if (digitalRead(buttonBpin) == LOW)

  {

    digitalWrite(ledPin, LOW);

  }

Reflection:

This week was rough. Any brainpower I had to work on this week's activity was spent. To be honest, I'm shocked I got the boards going at all. I got a resistor stuck in my bread board on d2 that is 100% not coming out (literally broken and stuck inside), so there's that. I tried the potentiometer again with the advice that is wasn't in all the way and one prong still refuse to go in. After the resistor incident I stopped trying for the sake of the board.  After all, what di she do to deserve such destruction? In all seriousness, I did come to the conclusion that, for the most part, it's not my setup that's wrong. I, 1) need to remember to verify and upload the code before expecting the board to work (duh), and 2) need to practice more on the coding part. What is confusing me is all of the notes in the code when i copy and paste it. I'm not always sure what I am supposed to change because I can't always find the part of the code I need to adjust. I also noticed that if I attempt the week's activity by doing what is listed on the SIK tutorials, it differs what I can open up and play with on the ELGOO lessons. This is why I had to laugh at myself in the multi LED video because on one trial I got the lights to switch by changing the number of the LED I wanted on. Then I used the SIK code and it was flashing like a Christmas tree. Wish I could say I recognized the difference between the two but I couldn't. I am hoping that not that I have a pretty good grasp of how to set up my board I can shift focus to coding. 

As far as real world connections the SIK site noted that RGBs are used in gaming. These also remind me of the LED strips people use to put behind televisions or my sons like to have in their rooms. They use the remotes to change colors, color patterns, pattern speed, and brightness. 

Comments

Popular posts from this blog

Final Post

Week 1: Reflecting on Web 2.0 and Technology in the Classroom