Our “tree of knowledge” has a new program. The colour change is more slowly (gives a more intensive experience :), the short range of red colours is extended by passing red even more slowly, and the tree is now communicative: the lights turn all red and do not turn out when someone appoaches. The arduino code is below.
#include <Wire.h>
/*
* Tree Of Knowledge --
* Tree with 30 BlinkM led modules
* The modules are connected using I2C. The blinkM routines are taken from
* the blinkM website: http://thingm.com/
* Tree connections to Arduino
* PWR - -- gnd -- blue -- Gnd
* PWR + -- +5V -- red -- 5V
* I2C d -- SDA -- yellow -- Analog In 4
* I2C c -- SCK -- green -- Analog In 5
*
* original version from E. Dertien with changes from A. Mader, 3 june 2009
*/
#include "Wire.h"
#include "BlinkM_funcs.h"
#define BLINKM_ARDUINO_POWERED 1
int hue[32], stap, sense; // each ball has now its own colour variable
int sensePin=0;
void setup()
{
BlinkM_begin();
Serial.begin(9600);
BlinkM_stopScript(0); // addr 0 means to all blinkm's. This command stops pre-programmed sequences.
for (int ball=1; ball<31; ball++) //check all balls visually
{
hue[ball] = 3*ball+100;
BlinkM_setFadeSpeed( ball, 255 );
BlinkM_fadeToHSB( ball, 25, 0xff, 0xff );
BlinkM_fadeToHSB(ball-1, 0x00, 0xff, 0x00 );
delay(100);
}
}
void loop()
{
int ball;
sense = analogRead(sensePin);
if (sense>350)
{ // case: someone is approaching the tree, the apples turn red
for(ball=1; ball<31; ball++)
{hue[ball]=int(ball-25)%255; // this is approximately the range of red colours
BlinkM_fadeToHSB( ball, hue[ball], 0xff, 0xff );};
}
else
{ // case: stand-alone tree where colours are changing
for(ball=1; ball<31; ball++)
{if ( (hue[ball]>235) or (hue[ball]<25)) {stap=1; delay(10);} else {stap=3;};
// in the red range the colour cange is by step of 1,
hue[ball]=(hue[ball]+stap)%255;
BlinkM_setFadeSpeed( ball, 1 ); // this is a slow fade
BlinkM_fadeToHSB( ball, hue[ball], 0xff, 0xff);
} }
//Serial.println(sense);
delay(400);
}
- BROWSE / IN TIMELINE
- « reflection(s) — on creativity
- » How many lives can a person have?
- BROWSE / IN Source Code
- « Tate exhibition – now in processing
SPEAK / ADD YOUR COMMENT
Comments are moderated.

