This weeks project involves analog outputs. Digital outputs answer yes or no questions (1 or 0, on or off, etc), while analog outputs cover the range of possibility (how fat is this cat? There is a scale / range). The first thing I found in my kit when I purchased it was an RGB LED light, and I have wanted to control the color output ever since.
I stopped by the NYU computer store to buy 2 additional potentiometers, since I need one for each light. Having learned the right way to solder this week (a skill I will definitely need), I began by soldering a power, sensor output, and ground wire to both pots.
Now that I had all my pieces ready, the first step was to get input readings from all three potentiometers. I connected all of them to power, ground, and different Analog ports. I chose ports 0,1 and 3 cause that was the best way to fit all three of them in on the narrow space that is the arduino board.
Next, I connected the RGB LED light on my board. This type of RGB has four prongs coming out of it, one for each color and a common anode (a common power (+) source for all 3 lights). I connected the power to a 220k resistor, followed by the common anode of the LED. Since I need the colors of the light to change according to what output I get from my potentiometers, I connected the 3 lights to ports 9, 10, and 11, since these ports are enabled with Pulse Width Modulation (pwm) which allows for analog variations between fully on and fully off (not all ports on the Arduino offer this).
Circuit diagram for my project
Here is the finalized code:
//Using 3 Pots to control an RGB LED
const int analogInPinRed = 0;
const int analogOutPinRed = 9;
const int analogInPinGreen = 1;
const int analogOutPinGreen = 10;
const int analogInPinBlue = 3;
const int analogOutPinBlue = 11;
int sensorValueRed = 0;
int outputValueRed = 0;
int sensorValueGreen = 0;
int outputValueGreen = 0;
int sensorValueBlue = 0;
int outputValueBlue = 0;
void setup(){
Serial.begin(9600);
}
void loop(){
//setting up the relationships between the pot reading and the output values allowed
sensorValueRed = analogRead(analogInPinRed);
outputValueRed = map(sensorValueRed, 0, 1023, 0, 255);
sensorValueGreen = analogRead(analogInPinGreen);
outputValueGreen = map(sensorValueGreen, 0, 1023, 0, 255);
sensorValueBlue = analogRead(analogInPinBlue);
outputValueBlue = map(sensorValueBlue, 0, 1023, 0, 255);
//writing the input reading to the lights
analogWrite(analogOutPinRed, outputValueRed);
analogWrite(analogOutPinGreen, outputValueGreen);
analogWrite(analogOutPinBlue, outputValueBlue):
}
And here are some pictures (video pending):
That is it for now. I will take video and upload it soon. I also want to try another project before class on Wednesday (probably something with the photocell and LED).

