Light and Interactivity

Interruptible LED fade

I’m so lucky to be a part of this class called Light and Interactivity, and so lucky to be a part of Tom’s class.

Tom talking about Vermeer was my fav part of last class, I was always fascinated by the lighting technique he used. Well, most of his drawings are indoors, however I was also fond of one’s his outdoor painting View of Delft.

The flicking lighting on the river draw people’s first attention on this painting, and then you notice the two human figures standing by the shore, and the cloudy sky, no matter where the viewer’s eyes may stare at, the lake’s flicking light is always in sight, creating this whole peaceful surrounding.

Consider myself sensitive to light, I can’t wait for what I would learn through out this semester.

Well, we are going to build a interruptible LED using a  button, on the first week of our class I just realized I may have forgotten PCom… felt like the last semester never existed? But luckily, Arduino has example codes.

So here is my code. Using a button to control interrupt a fading LED light. The brightness of the LED was controlled by keep + or – a fade amount, which is a fixed value.

const int buttonPin = 2;
const int ledPin = 11;
int brightness = 0;
int fadeAmount = 3;

int buttonState = 0;
void setup() {
 // put your setup code here, to run once:
 pinMode(ledPin, OUTPUT);
 pinMode(buttonPin, INPUT);

void loop() {
 buttonState = digitalRead(buttonPin);
 if (buttonState == HIGH) {
 digitalWrite(ledPin, 0);

} else {
 analogWrite(ledPin, brightness);
 brightness = brightness + fadeAmount;
 if (brightness <= 0 || brightness >= 255) {
 fadeAmount = -fadeAmount;

One of the problems I faced is that I failed to find the right pin for the analog output…

One problem with the code is that using Sin and Cos may helping the light to have a more “breathing” feel. I used that in my Fortune on Hand project.

Something like this.

int Pin = 3;

void setup()
 pinMode(Pin, INPUT);

void loop()
 float something = millis()/5000.0;
 int value = 128.0 + 128 * sin( something * 2.0 * PI  );

Leave a Reply

Your email address will not be published. Required fields are marked *