Week 10 Lab Report by Frank Mason

Objective: To use three potentiometers to individually control one RGB LED Light.

Materials: Arduino Duemilanove board, USB Cable for Ardunio Cable, 2 Breadboards, 3 Potentiometers, and 10 Jumper Cables to connect breadboard with Arduino (to create a fully functional circuit), and luck, a LOT of it.

Procedure:

1. Gather materials.

2. Wait for materials to arrive.

3. Connect USB Cable to Arduino Board.

4. Load the “Blink” example from the Arduino Example library to test whether your Arduino board is working.

5. Reset the Arduino Board of its code.

6. Connect all of the analog pins of the RGB Led Light and Jumper Cables to one of the breadboard (the other will be used for the potentiometers).

7. Connect Jumper Cables and the three potentiometers to the second breadboard.

8. Load the code from the Arduino website titled RBG LED Color Chooser.

*This is the code used for the Potentiometers and their control of the Ardunio:

  1. // Init the Pins used for PWM
  2. const int redPin = 9;
  3. const int greenPin = 10;
  4. const int bluePin = 11;
  5. // Init the Pins used for 10K pots
  6. const int redPotPin = 0;
  7. const int greenPotPin = 1;
  8. const int bluePotPin = 2;
  9. // Init our Vars
  10. int currentColorValueRed;
  11. int currentColorValueGreen;
  12. int currentColorValueBlue;
  13. void setup()
  14. {
  15.   pinMode(redPin, OUTPUT);
  16.   pinMode(greenPin, OUTPUT);
  17.   pinMode(bluePin, OUTPUT);
  18. }
  19. void loop()
  20. {
  21. // Read the voltage on each analog pin then scale down to 0-255 and inverting the value for common anode
  22.   currentColorValueRed = (255 – map( analogRead(redPotPin), 0, 1024, 0, 255 ) );
  23.   currentColorValueBlue = (255 – map( analogRead(bluePotPin), 0, 1024, 0, 255 ) );
  24.   currentColorValueGreen = (255 – map( analogRead(greenPotPin), 0, 1024, 0, 255 ) );
  25. // Write the color to each pin using PWM and the value gathered above
  26.   analogWrite(redPin, currentColorValueRed);
  27.   analogWrite(bluePin, currentColorValueBlue);
  28.   analogWrite(greenPin, currentColorValueGreen);
  29. }

Result: Somehow, someway, we finally got the RGB Light to work after an hour and a half of trial and error. It turns out that one of our major problems was faulty jumper cables. Another problem was the very stubborn breadboard, the holes of the breadboard were slightly deceptive given the plastic cover layered on top of the breadboard, which made it difficult to insert any jumper cables as well as the pins of the RGB LED Light into it.

This entry was posted in journals. Bookmark the permalink.

Leave a Reply