Light Controller


This assignment was very challenging for me. I started off working alone, being able to control 3 potentiometers with 3 RGB LEDs, which each showed either Red, Green, or Blue. Although, the pots were controlling the LEDs, I wanted there to just be 1 pot and 1 LED. And then I moved on to work with Jesal, who was having a different issue– he was using 1 LED and 1 Pot, but wasn’t able to control the LED in the way he wanted. We began working together and eventually were able to move to 1 LED being controlled by 3 potentiometers. We had issues with mapping along the way, for example, when we were at 672, which was our max for the pots, the LEDs were showing zero values. Regardless, of the mapping working in the opposite way, we were happy it was working. Then we moved to adding a switch to turn everything off and on. For whatever reason when I ran into this step during the past week, it’s where I had the most trouble. We eventually decided to work on the enclosure and worry about the switch after. Jesal then laser cut a shoe box we had, and I soldered the pots, LEDs, and button. However, when we came back just to assemble everything, nothing worked! We were reading completely different values for the pots. And without understanding, the LED now just blinks between all of the colors. Ultimately, we decided to cut our losses and house everything and hope a miracle would ensue in the day to come.

Circuit Diagram


const int analogInPin1 = A0; //red
const int analogInPin2 = A1; //green
const int analogInPin3 = A2; //blue
const int analogOutPin1 = 9; // Analog output pin that the LED is attached to
const int analogOutPin2 = 10;
const int analogOutPin3 = 11;

int turnon = 6;
int previousButtonState = LOW;

int sensorValue1 = 0;
int outputValue1 = 0;
int sensorValue2 = 0;
int outputValue2 = 0;
int sensorValue3 = 0;
int outputValue3 = 0;

//#define COMMON_ANODE
void setup() {
// initialize serial communications at 9600 bps:
pinMode(turnon, INPUT);

////pinMode(LEDpin, OUTPUT);
// pinMode(turnon, INPUT);
// digitalWrite(turnon, HIGH); // turn on pullup resistor


void loop() {
// if(digitalRead(turnon) == HIGH) {

// read the analog in value:
sensorValue1 = analogRead(analogInPin1);
// map it to the range of the analog out:
outputValue1 = map(sensorValue1, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin1, outputValue1);

sensorValue2 = analogRead(analogInPin2);
// map it to the range of the analog out:
outputValue2 = map(sensorValue2, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin2, outputValue2);

sensorValue3 = analogRead(analogInPin3);
// map it to the range of the analog out:
outputValue3 = map(sensorValue3, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin3, outputValue3);

// print the results to the serial monitor:
Serial.print(“sensor1 = “);
Serial.print(“\t output1 = “);

Serial.print(“sensor2 = “);
Serial.print(“\t output2= “);

Serial.print(“sensor3 = “);
Serial.print(“\t output3 = “);

// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
// }
//else {
// if (digitalRead(turnon) == LOW) {
// Serial.println(“fuck your mom”);
//// digitalWrite(analogInPin1) = LOW;
//// digitalWrite(analogInPin2) = LOW;
//// digitalWrite(analogInPin3) = LOW;
// digitalRead(turnon) == LOW;
// }




Getting 3 Pots to control 3 RGB LEDs

1 Pot controlling 1 RGB LED

Board before soldering

Front of controller

Back of controller


Turn ON an LED with a Button and Arduino – Tutorial #4