# Theory and Practice of Tangible User Interfaces

### Announcements

November 24, 2007
Reading for November 27th, are now posted. Enjoy!

October 2, 2007
To upload your thoughtless acts, create a new assignment page like any other lab. You'll see "Thoughtless Acts" listed as one of the assignment options.

May 24, 2008
This site has been archived and is no longer editable. Stay tuned for the next version, coming in the fall!

# LEDs and Potentiometers

Project Members:
Kimberly_Lau

### Description

Use multiple potentiometers to control and manipulate the

I modified the code to create a Christmas light-like
decoration, where the three LEDs blink in succession repeatedly as with lights on a Christmas tree. The LEDs can be controlled by one potentiometer,
so the lights blink in a constant time interval. Or the LEDs can be controlled by individual potentiometers, as in this case, with two LEDs controlled by one potentiometer and
the remaining controlled by another potentiometer.

### Components Used

Blue LED
Red LED
Green LED
Arduino board
Three 220-ohm Resistors (red, red, brown, gold)
2 Potentiometers

### Arduino Code

/*

* one pot controls the blinking rate of two LEDs, the
other pot controls the other LED

* modification of the
following

*Kimberly Lau

*/

int pot1Pin = 0; // select
the input pin for the potentiometer 1

int pot2Pin = 1; // select
the input pin for the potentiometer 2

int pot1Val = 0; // variable
to store the value coming from pot 1

int pot2Val = 0; // variable
to store the value coming from pot 2

int led1Pin = 9; // select
the pin for the LED 1

int led2Pin = 11; // select
the pin for the LED 2

int led3Pin = 10; // select the pin for the LED3

void setup() {

pinMode(led1Pin, OUTPUT); // declare the led1Pin as an OUTPUT

pinMode(led2Pin, OUTPUT); // declare the led2Pin as an OUTPUT

}

void loop() {

pot1Val = analogRead(pot1Pin); // read the value from pot 1, between 0 - 1024,
for dimming

pot2Val = analogRead(pot2Pin); // read the value from pot 2, between 0 - 1024,

analogWrite(led2Pin,
pot2Val/4); // dim LED to value from pot1

delay(pot2Val); // stop the program for some
time, meaning, LED is on for this time

analogWrite(led2Pin,
0); // dim LED to completely dark
(zero)

delay(pot2Val); // stop the program for some
time, meaning, LED is OFF for this time

analogWrite(led3Pin,
pot2Val/4);

delay(pot2Val);

analogWrite(led3Pin,
0);

delay(pot2Val);

analogWrite(led1Pin,
pot1Val/4);

delay(pot1Val);

analogWrite(led1Pin,
0);

delay(pot1Val);