• projects.
    • neon space moon.
    • the shape of refractive memory.
  • places.
    • new york.
    • bali.
    • paris.
    • los angeles.
    • australia.
    • japan.
    • sedona.
    • england.
  • people.
    • sports.
    • portraits.
    • events.
  • things.
    • wildlife.
  • itp blog.
    • itp_general.
    • itp_icm_f18.
    • itp_physical computing_f18.
    • itp_video&sound_f18.
    • itp_visual language_f18.
    • itp_animation_f18.
    • itp_wearables_s19
    • itp_fandom_s19
    • itp_turning_s19
    • itp_uxdesign_s19
    • itp_fungus_s19
    • itp_softrobotics_s19
    • itp_augmentedreality_f19
    • itp_fabrication_f19
    • itp_light&interactivity_s20
  • connect with me.
  • Menu

Madshutter Photo

  • projects.
    • neon space moon.
    • the shape of refractive memory.
  • places.
    • new york.
    • bali.
    • paris.
    • los angeles.
    • australia.
    • japan.
    • sedona.
    • england.
  • people.
    • sports.
    • portraits.
    • events.
  • things.
    • wildlife.
  • itp blog.
    • itp_general.
    • itp_icm_f18.
    • itp_physical computing_f18.
    • itp_video&sound_f18.
    • itp_visual language_f18.
    • itp_animation_f18.
    • itp_wearables_s19
    • itp_fandom_s19
    • itp_turning_s19
    • itp_uxdesign_s19
    • itp_fungus_s19
    • itp_softrobotics_s19
    • itp_augmentedreality_f19
    • itp_fabrication_f19
    • itp_light&interactivity_s20
  • connect with me.
box_fade.gif

Interruptible LED Fade

Project One | Interruptible LED Fade

February 03, 2020

For this project I chose to use two different fade methods; 1. Sin Fade & 2. Exponential Fade (for the interruption) from Tom Igoe’s Light Projects repo on Github. Essentially, the light will fade in congruence with the direction the sin wave until the button is pressed and the fade of the light will be interrupted with an immediate increase to 255 brightness or decrease to 0 brightness. Immediately after an interruption that takes the brightness to 0, there will be exponential increase to the brightness to 255 and then back down to the brightness of the light was the the sin fade (prior to button being pressed). See image of Arduino Plotter and code below:


Screen Shot 2020-02-01 at 7.08.43 PM.png

int led = 5;

int button = 2;

int buttonState = 0;

int lastButtonState = 0;

int brightness = 255;

int shift = 1;

byte levelTable[256];

byte expo[256];


void setup() {

Serial.begin(9600);

pinMode(led, OUTPUT);

pinMode(button, INPUT);

fillLevelTable();

fillExpo();

}


void loop() {

buttonState = digitalRead(button);

if (brightness <= 0 || brightness >= 255) {

shift = -shift;

}

brightness += shift;

analogWrite(5, levelTable[brightness]);

delay(10);

Serial.println(levelTable[brightness]);

if (buttonState != lastButtonState) {

if ( buttonState == HIGH) {

for (int brightness = 255; brightness >= 0; brightness += 5 ) {

analogWrite(5, expo[brightness]);

Serial.println(expo[brightness]);

delay(45);

} }

else {

if ( buttonState == LOW) {

for (int brightness = 0; brightness <= 255; brightness += 5 ) {

analogWrite(led, expo[brightness]);

Serial.println(expo[brightness]);

delay(45);

}}

delay(1);

}

lastButtonState = buttonState;

}}


void fillLevelTable() {

float maxValue = 255;

for (int l = 0; l <= maxValue; l++) {

float angle = map(l, 0, maxValue, 0, 179);

float lightLevel = (sin((angle * PI / 180) + PI / 2) + 1) * 127.5;

levelTable[l] = lightLevel;

}}

void fillExpo() {

float maxValue = 255;

float scalingFactor = (maxValue * log10(2)) / (log10(255));

for (int l = 0; l <= maxValue; l++) {

int ltLevel = pow(2, (l / scalingFactor)) - 1;

expo[l] = ltLevel;

}}


I programed an Arduino MKRZERO with the above code and breadboard w/ yellow LED and simple switch to emulate the interaction with the LED.

Screen+Shot+2020-02-03+at+4.56.59+PM.jpg

Once this was in good working operation, I found to learn to explore the junk shelf (aka free store) for inspiration. With the requirement being that a light source could not be seen, I was immediately lit up by finding a fiber optic piece from a toy that I could easily glue to an LED. I found a square pushbutton switch as well as a red LED in my tool box and began to solder the light and switch to header pins to connect to the breadboard and MKR Zero I used to program.

I wanted to package this up nicely so I used Make-A-Box IO to quickly draft up a box image that I could later use laser cut and fabricate together. I took the plan to Adobe Illustrator where I added holes for the components. I decided against drafting a hole for a cable as I was planning on using a litho battery but realized afterwards that I needed a larger battery so later drilled a hole in the box side to accommodate.

PDF box export from makeabox.io

PDF box export from makeabox.io

Screen Shot 2020-02-03 at 5.05.32 PM.png

Completed project below:

Uploaded by Madison R Rosner on 2020-02-03.


Full list of materials:

(1) full-sized breadboard

(1) Arduino MKRZERO

(1) LED

(1) Button Switch

(1) Fiber Optic toy

(1) piece 12 x 12 Pine Plywood

(1) Micro USB cable

(#) wires to connect

(#) tape

(#) wood glue



Prev / Next

Donec sed odio dui.

Vestibulum id ligula porta felis euismod semper. Maecenas faucibus mollis interdum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor. Curabitur blandit tempus porttitor. Donec id elit non mi porta gravida at eget metus.

Sed posuere consectetur est at lobortis.

Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Aenean lacinia bibendum nulla sed consectetur. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Cras mattis consectetur purus sit amet fermentum. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.​