For this assignment I used 4 potentiometers and one press button. I mapped three potentiometer reading 0-255 per color. I used the forth potentiometer as a master, controlling the over all brightness and worked on two versions – one that controls the brightness and essentially makes the light very white and bright, and the other, controlling the power of the LED pin through it, and so just making a fader of the colors. The switch I used as a state control to start and stop the overall lights.

This is a test on the breadboard

The code – controlling the overall brightness, made after Tom walked me through the pseudo code.

// constants won’t change. They’re used here to
// set pin numbers:
const int switchPin = 2; // the number of the pushbutton pin

const int redPin = 11; // the number of the LED pin
const int greenPin = 10; // the number of the LED pin
const int bluePin = 9; // the number of the LED pin

const int potR = A0; // input pin for potentiometer controlling Red LED
const int potG = A1; // input pin for potentiometer controlling Green LED
const int potB = A2; // input pin for potentiometer controlling Blue LED

const int master = A3; // input pin for potentiometer controlling overall brightness

// variables will change:
int switchState = 0; // variable for reading the pushbutton status

void setup() {

// initialize the toggle switch pin as an input:
pinMode(switchPin, INPUT_PULLUP);

// initialize the LED pins as OUTPUTS:
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);

// initialize the potentiometers as an input:
pinMode(potR, INPUT_PULLUP);
pinMode(potG, INPUT_PULLUP);
pinMode(potB, INPUT_PULLUP);
pinMode(master, INPUT_PULLUP);

Serial.begin(9600);
}

void loop() {
// read the state of the pushbutton value:
switchState = digitalRead(switchPin);
Serial.println(switchState);

//Reading RGB pots
int potRValue = analogRead(potR);
//Serial.println(potRValue);
int potGValue = analogRead(potG);
//Serial.println(potGValue);
int potBValue = analogRead(potB);
//Serial.println(potBValue);

//Mapping RGB pots 0-255
int potRmapped = map(potRValue, 0, 1023, 0, 255);
//Serial.println(potRmapped);
int potGmapped = map(potGValue, 0, 1023, 0, 255);
//Serial.println(potGmapped);
int potBmapped = map(potBValue, 0, 1023, 0, 255);
//Serial.println(potBmapped);

//Reading Master pot
int masterValue = analogRead(master);
//Mapping Master 0-100
int masterMapped = map(masterValue, 0, 1023, 0, 100);
int red = (masterMapped * potRmapped / 100);
//Serial.println(red);
analogWrite(redPin, red);

int green = (masterMapped * potGmapped / 100);
// Serial.println(green);
analogWrite(greenPin, green);

int blue = (masterMapped * potBmapped / 100);
// Serial.println(blue);
analogWrite(bluePin, blue);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (switchState == HIGH) {
// turn LED on:
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);

}else (switchState == LOW){
// turn LED off:
digitalWrite(redPin, LOW);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, LOW);
}
}

The Fabrication

When I first moved from the breadboard, soldered the component to wires to put all in a separate box, there were problems with the connections. I went through the process again making sure all connections are solid and there were no loose or exposed wires. I hot glued any exposed edges as well. Now I was able to put it inside a new casing.

I couldn’t find the right resistors so put these in parallel and go the right resistance. Good tip from Druv.

I made knobs our of Sculpy. At first wanted to have red green and blue so I colored it with nail polish, but didn’t like how it came out so I made another version of the knobs in white, and just a hint of color at the top.

I made this enclosure last year in fabrication class, and always wanted to use it for some project, so took this chance to test again the experience of working with a round enclosure.

I took it apart and made a new layout for the lighting controllers on illustrator. I cut an acrylic sheet I saved from the junk shelf on the laser.

Here are the variations I made –

Testing of the lighting diffusion –

changed the knobs –

to warm up I went through this intructable to play around with the rgb LED values:

I played around a lot with velostat and mapped it’s readings when touched to 0-255 per color. It was nice to see the color changed when playing with the material, but it is very hard to get a range, and it basically operated like an of/on switch. Also I wanted to have 3 controllers for r, g and b but one of the piece would generate any values. The conclusion was that there might have been not enough conductive material on it’s sides, but I didn’t get to test and confirm that yet.