On Time Intelligent Light Switch

Presenting the final for my On Time Intelligent Light Switch. The process was a pretty fun ride with a few twists, turns, and mishaps along the way. The Code was more complex than I expected going in. I AM happy with how its functioning, but I am learning so many different ways of getting to the same result, that I believe this code could be written in a few different ways which would leave it more open to easier modifications and distinct separate states of operation.

The final cluster of components is also larger than I originally envisioned. A little too large to cleanly fit into the wall as an at home switch replacement. Have already been looking into some alternative boards to do the dimming which I hope will drive the next update to the concepts to actually find a home within the walls of my home.

My very first Instructable post can be found below.  : https://www.instructables.com/id/On-Time-Light-Switch

Some Photos from the construction process. :

Wiring Diagram.jpeg

Tools.jpg

Parts1.jpg

3b-Wired Breadboard.jpg

5-AC in Wallbox.jpg

6a-All Wired.jpg

6b-All Wired.jpg

9-Finished.jpg

 

 

Final Project Proposals.

My three ideas all revolve around home automation. Something I have long desired to geek out in.

Concept 1 – On-Time Light Switch

On-Time Light Switch.jpeg

The idea is to replace the light switch in my wall with an Arduino, a motion sensor and an arcade button.

The Arduino will connect with an online calendar to drive several different behaviors.

  • Night time : lights turn on low or dimmed. They stay on for 1 min.
  • Morning (but after my alarms) : Light fades up from dim to bright. They stay on for 10 min.
  • Morning Routine (class days) : Lights blink/fade to indicate the amount of time until departure. 30 min out / 15 min out / 5 min out / GO
  • Arcade button flips through several preset behaviors (eg, guest mode, cleaning time, entertaining, etc)

 

Concept 2 – Guitar Pedal Wireless Light Control Center

Light Control Center.jpg

This device would act as Mission Control for a bunch of relays and dimmers that are running on each cluster of lights in each of the zones of my apartment.

The rocking pedal adjusts the “effect” be it brightness, color, pattern, etc. Primarily brightness.

The other buttons and switches control the different “zones of light. (each room tends to have both direct and ambient lighting.)

 

Concept 3 – Guitar Pedal Wireless iTunes control

iTunes Control.jpg

The rocking on the pedal will adjust the master volume. The tap switch pauses and plays the music.

Additionally, I would like to imbed the ability for it to auto-pause when I leave the apartment/area and to play again when I get home.

 

 

LED Vest in action.

Here is the starting sketch of the concept.

Color-Stealing-Suspenders.jpg

It quickly evolved into a vest format to ease up the complication of trying to fit everything in the suspender format.

I went a little overboard on the construction process by making a silicone sleeved , heat-shrink sealed, 10 LED unit that joined together with a connector. While this left me with a lot of versatility, it took way to long to construct.

You can see the overly involved construction process in these videos.

The final assembly ended up super durable, as it traveled well to Vegas stuffed in a carry-on (the TSA was very curious about it),  was stepped on, and had beer spilled on it during a concert.

The original intent of making it sample colors and add this into the animations was scrapped, as I was having some difficulty in figuring out how to integrate a sampled color into the LED animations that I was using within the time constraints I had. This is definitely something I am interested in figuring out in the future.

The final direction I went in was a series of animations that drove through 4 sets of parallel neopixel strips, with a push button cycling through the different animations.

The biggest leaning I found from the field was the brightness. It was WAY too bright to use during a concert. This was adjusted down to 40% following night one, but found that was still not enough. I made a scrambled attempt to integrate a potentiometer into the circuit to control the brightness, but may have been too intoxicated to pull this off.

Moody Raindrop

Sometimes it feels good to be a little blue when it’s raining. Sometimes you want to feel blue, but there just isn’t any real rain in sight. The Moody Raindrop provides you with the ability to get a little emotional any time you wish.

The white felt plushy resembles a single drop of rain that reveals its melancholy mood when inner-lit with blue light.

IMG_6689.jpg

Concept Sketch

Drop Sketch.jpg

WORKSPACE

Prepping the workspace

IMG_6671.jpg

PATTERN

Layout and cutting the pattern

IMG_6672.jpgIMG_6673.jpgIMG_6675.jpgIMG_6677.jpg

I ended up stitching by hand. Thought I could use the experience/training of stitching by hand.. Hindsight says I should have used the machines for better cleaner edges.

IMG_6678.jpgIMG_6679.jpgIMG_6680.jpg

(not pictured : gluing the blue felt eyes and quivering mouth to the inside of the felt before turning inside out.)

IMG_6684.jpg

ELECTRONICS

The LED cluster was essentially the same as last week with the blue LEDs glued into the styrofoam spheres, but I added a 5th light and heat-shrined+hot-glued the cluster of 5 lights together for a more even dispersal inside the final model.

IMG_6681.jpgIMG_6682.jpgIMG_6683.jpg

Plush wiring diagram.png

ASSEMBLY

The sewn felt skin and the electronics cluster come together with a hint of fiberfill to fill out the edges of the plush and to help diffuse the light another level.

The diffusion ended up OK, but not amazing. Still have hot spots in the center and a little dark around the edges. That said, my intended reveal of the eyes and mouth work like a charm.

Off – under light

IMG_6686.jpg

ON-under light

IMG_6692.jpgIMG_6690.jpg

ON – under little ambient light

IMG_6689.jpg

 

Blue Rain

PROTOTYPE

A teardrop becomes moody blue when lit from the inside.

The prototype was constructed of white felt with a blue stitch.

Eyes were glued to the inside with the idea of revealing the mood when turned on.

IMG_6657.jpegIMG_6656.jpeg

4 LED’s were connected in parallel to the battery (resistors will be needed for the final design), then inserted into styrofoam spheres for diffusion.

Parallel Wired LED ClusterIMG_6651.jpeg

LED’s inserted into spheres

IMG_6652.jpeg

IMG_6653.jpeg

 

Spheres wrapped in stuffing before being loaded into the prototype IMG_6655.jpeg

DIFFUSION TESTS

I tested several methods for diffusing the LED light.

Nylon Mesh Weave

IMG_6637.jpegIMG_6638.jpeg

 

Glow in the dark “fingers”

IMG_6636.jpegIMG_6635.jpeg

 

Ping Pong Balls

IMG_6639.jpeg

IMG_6640.jpeg

 

Polypropylene tubes

IMG_6641.jpegIMG_6642.jpeg

 

Styrofoam spheres

IMG_6643.jpegIMG_6644.jpeg

 

and Opaque plastic cylinders

IMG_6646.jpegIMG_6647.jpeg

In the end, I found the Styrofoam spheres to deliver the best look to the diffusion. The ping-pong balls were a close second, but too large for the concept I’m thinking about.

W-3 Arduino Work

Smooth sailing with most of the exercises, but tried to write code from scratch out of the “getting started with Arduino” book (Example 5-2. Sketch to change the brightness as you hold the button) and totally failed to get off the ground. Code and board image are below.. Would love some help in figuring what I’ve done wrong.

Digital Input – Original

Digital Input – Reversed

Serial monitor

Analog Input

 

Example 5-2. Sketch to change the brightness as you hold the button

Board Layout

IMG_6628.jpeg

Unsuccessful Code Attempt

 

/*
  Fade with button Adjust (test coding from Bart)

*/

const int LED = 9; // the pin for the LED
const int BUTTON = 7;  //input pin of the pushbutton

int val = 0; // stores the state of the input pin

int old_val = 0;  // stores the state of the input pin
int state = 0;  // 0 = LED off while 1 = LED on
int brightness = 128; // stores the brightness value
unsigned long startTime = 0; // when did we begin pressing?

void setup() {
  pinMode(LED, OUTPUT); // tell Arduino LED is an output
  pinMode(BUTTON, INPUT); //and BUTTON is an input
}

void loop() {

  val - digitalRead(BUTTON); // read input value and store it

  // check if there was a transition
  if ((val == HIGH) && (old_val == LOW)) {

    state = 1 - state; //change the state from off to on or vise-versa

    startTime = millis(); // millis() is the arduino clock
                          // it returns hom many milliseconds havbe passed since the board has been reset

    // (this line remembers when the button was last pressed)
    delay (10);
  }

  // check whether the button is being held down
    if ((val == HIGH) && (old_val == HIGH)) {

      // if the burron is held for more than 500ms. 
      if (state == 1 && (millis() - startTime) > 500) {

        brightness++;  //increment brightness by 1
        delay(10); // delay to avoid brightness going up too fast

        if (brightness > 255) { // 255 is the max brightness
          brightness = 0; // if we go over 255 let's go back to 0
        
        }
      }
    }

    old_val = val; // val is now old, let's store it

    if (state == 1) {
      analogWrite(LED, brightness);  // turn LED ON at the current brightness level
      
    } else {
      analogWrite(LED, 0); // turn LED OFF
    }
    
}