Mood Jar

For “Mood Jar” I assembled a circuit that connected two potentiometers–one tall, one short–to three LEDs, and put the whole assembly into a jar sprayed with frosted glass spray paint. While I originally wanted to have rotating the lid of the jar activate one of the switches, and rotating the “cuff” of the lid activate the other, this proved difficult and so I did what felt like the right thing to do at the time: drilled holes.

The first potentiometer emerging from the first hole controls the color, which can be “any color” along the range of colors we produced last week with our inputs. The other dial controls blink speed. Overall I think it needs more frosting for diffusion, and given enough coats I think a solid diffusion could be accomplished.

 

Materials:

1 Jar

1 Arduino Micro

Wires

Solder/Soldering Iron

2 Potentiometers

3 Resistors (220 Ohms)

3 LEDs

Hot glue gun/hot glue

Frosted Glass spray paint

 

Code:

 * Modified version of: RGB Pot Mixer2
 * --------------
 *
 * Code for making one potentiometer control 3 LEDs, red, grn and blu, 
 * or one tri-color LED.
 *
 * Uses a purportedly correct algorithm for converting a hue number into RGB values
 * 
 * Code assumes you have the LEDs connected in a common-anode configuration,
 * with the LED's anode connected to +5V via a resistor and the cathode connected
 * to Arduino pins 9,10,11. 
 *
 * Tod E. Kurt <tod@todbot.com>, serial debug by Clay Shirky
 *
 */
// INPUT: Potentiometer should be connected to 5V and GND
int potPinColor = A4; // Potentiometer output connected to analog pin 3
int potPinBlink = A5; // Second potentiometer controlling blink speed
int potValColor = 0; // Variable to store the input from the potentiometer
int potValBlink = 0; // Variable to store the input from the second potentiometer (controlling blink)

// OUTPUT: Use digital pins 9-11, the Pulse-width Modulation (PWM) pins
// LED’s cathodes should be connected to digital GND
int redPin = 9; // Red LED, connected to digital pin 9
int grnPin = 10; // Green LED, connected to digital pin 10
int bluPin = 11; // Blue LED, connected to digital pin 11

// Program variables
int redVal = 0; // Variables to store the values to send to the pins
int grnVal = 0;
int bluVal = 0;

void setup()
{
pinMode(redPin, OUTPUT); // sets the pins as output
pinMode(grnPin, OUTPUT);
pinMode(bluPin, OUTPUT);
}

// Main program
void loop()
{
potValColor = analogRead(potPinColor); // read the potentiometer value at the input pin
potValBlink = analogRead(potPinBlink);

if (potValColor < 341) // Lowest third of the potentiometer’s range (0-340)
{
potValColor = (potValColor * 3) / 4; // Normalize to 0-255

redVal = 256 – potValColor; // Red from full to off
grnVal = potValColor; // Green from off to full
bluVal = 1; // Blue off
}
else if (potValColor < 682) // Middle third of potentiometer’s range (341-681)
{
potValColor = ( (potValColor-341) * 3) / 4; // Normalize to 0-255

redVal = 1; // Red off
grnVal = 256 – potValColor; // Green from full to off
bluVal = potValColor; // Blue from off to full
}
else // Upper third of potentiometer”s range (682-1023)
{
potValColor = ( (potValColor-683) * 3) / 4; // Normalize to 0-255

redVal = potValColor; // Red from off to full
grnVal = 1; // Green off
bluVal = 256 – potValColor; // Blue from full to off
}
analogWrite(redPin, redVal); // Write values to LED pins
analogWrite(grnPin, grnVal);
analogWrite(bluPin, bluVal);
delay(potValBlink);
analogWrite(redPin, redVal*0); // Write values to LED pins
analogWrite(grnPin, grnVal*0);
analogWrite(bluPin, bluVal*0);
delay(potValBlink);
}

https://youtu.be/UEiwWYq9T2I

https://youtu.be/zKnCbmoYxjU

 

20160921_062336 20160921_055043

Leave a Reply