« March 2008 | Main

April 23, 2008

Code for Arduino

Here's the code I've written for the Arduino; I'll comment it as necessary.


#include

TLC5940 leds(1, 8);

void setup() {
Serial.begin(115200);
leds.init();
leds.clear();
leds.display();
}

void loop() {
rainbow();
}

void colorLED(char current, char color) {
if (color == 1)
fullLEDset(current, 255, 0, 0);
if (color == 2)
fullLEDset(current, 255, 255, 0);
if (color == 3)
fullLEDset(current, 0, 255, 0);
if (color == 4)
fullLEDset(current, 0, 255, 100);
if (color == 5)
fullLEDset(current, 0, 0, 255);
if (color == 6)
fullLEDset(current, 255, 0, 255);
if (color == 7)
fullLEDset(current, 255, 255, 255);
if (color == 8)
fullLEDset(current, 0, 0, 0);
leds.display();
}

// The full LED set function takes in a number for the LED to be changed, followed by the RED, GREEN, and BLUE values specified.

void fullLEDset(char LED, char red, char green, char blue) {
leds.setLED(LED*3 - 2, blue);
leds.setLED(LED*3 - 1, green);
leds.setLED(LED*3, red);
leds.display();
}

// A simple algorithm that colors lights around the outside in a circular fashion.
void circle() {
int current = 1;
int color = 1;
int i;
while(1) {
if (current == 4) {
current = 0;
color++;

for (i = 0; i < 256; i++) {
leds.setLED(15, i);
leds.setLED(14, i);
leds.setLED(13, i);
leds.display();
delay(2);
}
for (i = 255; i > -1; i--) {
leds.setLED(15, i);
leds.setLED(14, i);
leds.setLED(13, i);
leds.display();
delay(2);
}
}
if (color == 7)
color = 1;
current++;
colorLED(current, color);
delay(250);
}
}

// A fade in and out for each color.
void breathe() {
int intensity;
int color = 1;
int red, green, blue;
while(1) {
red = 0;
green = 0;
blue = 0;
if (color == 4)
color = 1;
if (color == 1)
red = 1;
if (color == 2)
green = 1;
if (color == 3)
blue = 1;
for (intensity = 5; intensity < 120; intensity++) {
fullLEDset(1, red*intensity, green*intensity, blue*intensity);
fullLEDset(2, red*intensity, green*intensity, blue*intensity);
fullLEDset(3, red*intensity, green*intensity, blue*intensity);
fullLEDset(4, red*intensity, green*intensity, blue*intensity);
fullLEDset(5, red*intensity, green*intensity, blue*intensity);
delay(5);
}
for (intensity = 120; intensity > 4; intensity--) {
fullLEDset(1, red*intensity, green*intensity, blue*intensity);
fullLEDset(2, red*intensity, green*intensity, blue*intensity);
fullLEDset(3, red*intensity, green*intensity, blue*intensity);
fullLEDset(4, red*intensity, green*intensity, blue*intensity);
fullLEDset(5, red*intensity, green*intensity, blue*intensity);
delay(10);
}
color++;
}
}

// Completely random and seizure-inducing.
void randomStuff() {
int r, i;
while (1) {
r = rand() / 4096;
i = rand() / 6553 + 1;
colorLED(i, r);
delay(1);
}
}

// Fades between all the colors in the rainbow.
void rainbow() {
int red;
int green;
int blue;

red = 255;
green = 0;
blue = 0;

while (1) {
for (green = 0; green < 255; green++) {
fullLEDset(1, red, green, blue);
fullLEDset(2, red, green, blue);
fullLEDset(3, red, green, blue);
fullLEDset(4, red, green, blue);
fullLEDset(5, red, green, blue);
delay(2);
}
delay(1000);
for (red = 255; red > 0; red--) {
fullLEDset(1, red, green, blue);
fullLEDset(2, red, green, blue);
fullLEDset(3, red, green, blue);
fullLEDset(4, red, green, blue);
fullLEDset(5, red, green, blue);
delay(2);
}
delay(1000);
for (blue = 0; blue < 255; blue++) {
fullLEDset(1, red, green, blue);
fullLEDset(2, red, green, blue);
fullLEDset(3, red, green, blue);
fullLEDset(4, red, green, blue);
fullLEDset(5, red, green, blue);
delay(2);
}
delay(1000);
for (green = 255; green > 0; green--) {
fullLEDset(1, red, green, blue);
fullLEDset(2, red, green, blue);
fullLEDset(3, red, green, blue);
fullLEDset(4, red, green, blue);
fullLEDset(5, red, green, blue);
delay(2);
}
delay(1000);
for (red = 0; red < 255; red++) {
fullLEDset(1, red, green, blue);
fullLEDset(2, red, green, blue);
fullLEDset(3, red, green, blue);
fullLEDset(4, red, green, blue);
fullLEDset(5, red, green, blue);
delay(2);
}
delay(1000);
for (blue = 255; blue > 0; blue--) {
fullLEDset(1, red, green, blue);
fullLEDset(2, red, green, blue);
fullLEDset(3, red, green, blue);
fullLEDset(4, red, green, blue);
fullLEDset(5, red, green, blue);
delay(2);
}
delay(1000);
}
}

// A five bit counter implemented with a cube.
void count() {
char counter = 0;
char temp;
while(1) {
for (counter = 0; counter < 32; counter++) {
temp = counter;
if (temp >= 16) {
fullLEDset(5, 255, 0, 0);
temp = temp - 16;
}
else
fullLEDset(5, 0, 0, 0);


if (temp >= 8) {
fullLEDset(4, 255, 0, 0);
temp = temp - 8;
}
else
fullLEDset(4, 0, 0, 0);

if (temp >= 4) {
fullLEDset(3, 255, 0, 0);
temp = temp - 4;
}
else
fullLEDset(3, 0, 0, 0);

if (temp >= 2) {
fullLEDset(2, 255, 0, 0);
temp = temp - 2;
}
else
fullLEDset(2, 0, 0, 0);

if (temp >= 1)
fullLEDset(1, 255, 0, 0);
else
fullLEDset(1, 0, 0, 0);

delay(1000);
}
}
}

// Police siren.
void spin() {
while(1) {
fullLEDset(1, 255, 0, 0);
fullLEDset(3, 0, 0, 255);
fullLEDset(5, 255, 255, 255);
delay(250);
fullLEDset(1, 0, 0, 0);
fullLEDset(3, 0, 0, 255);
fullLEDset(2, 255, 0, 0);
fullLEDset(4, 0, 0, 255);
fullLEDset(5, 0, 0, 0);
delay(250);
fullLEDset(2, 0, 0, 0);
fullLEDset(4, 0, 0, 0);
fullLEDset(1, 0, 0, 255);
fullLEDset(3, 255, 0, 0);
fullLEDset(5, 255, 255, 255);
delay(250);
fullLEDset(3, 0, 0, 0);
fullLEDset(1, 0, 0, 0);
fullLEDset(2, 0, 0, 255);
fullLEDset(4, 255, 0, 0);
fullLEDset(5, 0, 0, 0);
delay(250);
fullLEDset(4, 0, 0, 0);
fullLEDset(2, 0, 0, 0);
}
}

// A quick flashing algorithm. I made this to determine exactly the delay necessary to look like "flashing" to the human eye.
void flash() {
while(1) {
fullLEDset(1, 255, 0, 0);
fullLEDset(2, 255, 0, 255);
fullLEDset(3, 0, 255, 0);
fullLEDset(4, 0, 0, 255);
fullLEDset(5, 255, 255, 0);
delay(15);
fullLEDset(1, 0, 0, 0);
fullLEDset(2, 0, 0, 0);
fullLEDset(3, 0, 0, 0);
fullLEDset(4, 0, 0, 0);
fullLEDset(5, 0, 0, 0);
delay(15);
}
}

// Stress test which forces the LEDs to be mostly on for a long period.
void stress() {
int first = 255, second = 51, third = 102, fourth = 153, fifth = 204;
while(1) {
fullLEDset(1, first, first, first);
fullLEDset(2, second, second, second);
fullLEDset(3, third, third, third);
fullLEDset(4, fourth, fourth, fourth);
fullLEDset(5, fifth, fifth, fifth);
first--;
second--;
third--;
fourth--;
fifth--;
if (!first)
first = 255;
if (!second)
second = 255;
if (!third)
third = 255;
if (!fourth)
fourth = 255;
if (!fifth)
fifth = 255;

delay(5);
}
}

April 22, 2008

Looks like someone had a similar idea...

I came across this and decided to share it.


http://www.abc.net.au/science/news/stories/2007/1991871.htm

April 17, 2008

Atmospheres of the cube seats

Breathing Space


The fabrication of the programmable lighting of the three cube seating elements is progressing well.

The concept of a breathing space will guide the design of the dynamic behavior of the cubes as we begin to think about them as programmable atmospheres that create responsive environments for experience.


Each cube seat has multiple modalities.

Each has it’s resting state, it’s responsive atmosphere when someone chooses to sit on it, as well as an additional mode as part of the collective atmosphere of the three cube seats in communication with one another.

These three modalities, resting, responsive and collective interaction guide the algorithms that we develop,

The notion of breathing space is key. What about the dynamic and responsive lighting and color shifts helps people to take a moment to shift from being in motion to being momentarily still.

How does this personal sense of taking a “breather" become a social experience?

How do the cube seats invite passersby to relax for a moment?