Assignment 3: Sensing Potentiometers

Assignment: Sensing: Potentiometers

Collaborators:

Description

I first did the 3 potentiometers controlling the hues / brightness of the 3 LEDs.  I used the code provided with the homework.

3 potentiometers controlling 3 LEDs

 

I then used 2 potentiometers to control 3 LEDs.  The first potentiometer controls the speed by which all 3 LEDs change colors.  The second LED determines the maximum brightness of the 3 LEDs.  Colors are determined by randomizing the RGB values between 0 and the maximum (as controlled by the 2nd LED).

Here is the circuit with a cotton diffuser:

Here is the circuit without a diffuser:

 

Components Used

3 Potentiometers

3 LEDs

3 Resistors

1 Cotton diffuser

 

Code

The code I used for the first part is attached at the Assignment 3 page.

The code I used for my own application is as follows:

 

// This program takes in input from one potentiometer

// to determine the amount of time before LEDs change color.

// The LEDs change color randomly.  The second potentiometer

// determines the maximum brightness that the LEDs can emit

// (thereby determining color intensity)

// Karen Joy Nomorosa

// September 23, 2009.

 

// Analog pin settings

int aIn = 0;

int bIn = 1;

 

//Digital pin settings

int aOut = 9;

int bOut = 10;

int cOut = 11;

 

//Values

int delayTime = 1000; // taken from potentiometer 1

int randomColor = 0; // taken from potentiometer 2

 

void setup()

{

pinMode (aOut, OUTPUT);

pinMode (bOut, OUTPUT);

pinMode (cOut, OUTPUT);

Serial.begin (9600);

}

 

void loop()

{

randomColor = random(analogRead (bIn)) / 4;

analogWrite (aOut, randomColor);

Serial.print ("A: " + randomColor);

 

randomColor = random(analogRead(bIn)) / 4;

analogWrite (bOut, randomColor);

Serial.print ("B: " + randomColor);

 

randomColor = random(analogRead(bIn)) / 4;

analogWrite (cOut, randomColor);

Serial.print ("C: " + randomColor);

 

delayTime = analogRead(aIn) * 100;

delay (delayTime);

}