# 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!

# Lab 3- Flowing light between 3 LEDs

Project Members:
Hsin-Hsien Chiu

Descriptions:

After being able to use 2 and 3 pots to control dimming and blinking speed of three RGB LEDs separately from the Lab 3 last week, I start to consider using one pot to discuss relationship between three LEDs. Thus, I try to use 3 pots controlling dimming, blinking speed, and lighting sequence of three RGB LEDs separately:

Pot 1 for dimming

Pot 3 for Lighting Flow (sequence)

For Pot 3, to make the light “flow” between 3 LED, there are five ranges defined for making the lighting sequence similar to a circle: Blue-Green-Red-Green-Blue. When the Target LED is lighten, the dimming degree and blinking speed could be controlled by Pot 1 and Pot 2. Using higher blinking frequency and lighting strength for the Target LED could make the phenomenon of “Lighting Flow” more clearly.

For the diffuser "Mood Egg", the lighting flow indicates the insight of one's feeling consciously/ subconsciously according to various variables.

For the diffuser "Alien Bean",  the lighting flow indicates some kinds of organic transformation or evolution triggered via different cosmos.

Components:

3 potentiometer pots, Arduino board, bread board, 3 RGB LEDs, 6 wires

Codes:

/*
*Pot 1 for dimming control, Pot 2 for blinking control, and Pot 3 for making lighting flow inbetween three LED
*by DojoDave <http://www.0j0.org>
*/

int pot1Pin = 0;   // select the input pin for the potentiometer 1
int pot2Pin = 1;   // select the input pin for the potentiometer 2
int pot3Pin = 2;   // select the input pin for the potentiometer 3
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 pot3Val = 0;   // variable to store the value coming from pot 3
int TargetLED = 11; // start from Blue LED
int RedPin = 9;   // select the pin for the Red LED
int GreenPin = 10;  // select the pin for the Green LED
int BluePin = 11;  // select the pin for the Blue LED

void setup() {
Serial.begin(9600);
pinMode(RedPin, OUTPUT);  // declare the RedPin as an OUTPUT
pinMode(GreenPin, OUTPUT);  // declare the GreenPin as an OUTPUT
pinMode(BluePin, OUTPUT);  // declare the BluePin as an OUTPUT
}

void loop() {
pot1Val = analogRead(pot1Pin);   // read the value from pot 1, between 0 - 1024, for dimming
pot3Val = analogRead(pot3Pin);   // read the value from pot 3, between 0 - 1024, to select output LED
Serial.println(pot1Val);

//To make the light flow between 3 LED, there are five ranges starting from B-G-R-G-B as smiliar to a circle
if (pot3Val > 801) TargetLED = 11;       // the range 801 - 1024 is for Green LED
else if (pot3Val > 601) TargetLED = 10;  // the range 601 - 800 is for Green LED
else if (pot3Val > 401) TargetLED = 9;   // the range 401 - 600 is for Red LED
else if (pot3Val > 201) TargetLED = 10;  // the range 201 - 400 is for Green LED
else TargetLED = 11;                     // the range 0 - 200 is for Blue LED

analogWrite(TargetLED, pot1Val/4);     // light the selected LED
delay(pot2Val);                  // stop the program for some time, meaning, LED is on for this time
analogWrite(TargetLED, 0);         // dim LED to completely dark (zero)
delay(pot2Val);                  // stop the program for some time, meaning, LED is OFF for this time
}

Image Description:

The picture atttached is shot with B-Carema shetter in the dark to show the "lighting flow" between three RGB LEDs.

http://photo.xuite.net/berkeleychiu/2005583/2.jpg

AttachmentSize
P9200058-small.jpg37.64 KB