Motion + sliders + light

Plumduino setup, hardware, basic programming. User to user support.
Airtent
Posts: 1
Joined: Tue Aug 11, 2015 3:27 pm

Motion + sliders + light

Postby Airtent » Fri Oct 07, 2016 5:41 am

I spliced the example code for changing color/brightness with the sliders plus turning on the leds when motion is detected by the expansion board.

The line where it turns the leds on:

setAllPixelsRGB(red,green,blue);

Is there a way to create a fade in effect like what happens in the kickstarter video to create more or less a motion controlled night light? Mainly interested in the smooth fade in effect and i couldn't really find any existing code from the examples that had that effect. Maybe also throw in code so that you trigger the motion sensor, lights fade to bright but stays on for at least x seconds until it gets another motion reading at which point it will cause the leds to fade out (or just a auto timeout after a while).

Also will there be instructions on how to solder the contact for a battery?


Full code below:

Code: Select all

#include "PlumduinoHardware.h"  // Leave this line first. Do not edit this line. This causes Arduino
                                // to include background functions when turning your code into
                                // machine language Wink can understand.

// Below is the "setup" function. It runs one time as soon as Plumduino turns on. You can add stuff
// to this function if you want, but hardwareBegin() should always be the first code in the list.

void setup(){
  hardwareBegin();        //initialize Wink's brain to work with his circuitry

}

int s1, s2;
int hue, brightness;

void loop() {

  s1 = analogRead(Slide1);          //read slider 1
  s2 = analogRead(Slide2);          //read slider 2

  hue = s1 * 0.35;                  //scale down 1024 scale of slider to 360 degrees
  brightness = s2 /4;               //scale down 1024 scale of slider to 255 brightness

  getColorWheel(hue, brightness);

  while (digitalRead(Motion) == LOW){
    setAllPixelsRGB(0,0,0);   //set all pixels to off
  }

  // code will continue here when the motion sensor pin goes high
  setAllPixelsRGB(red,green,blue);  //results of getColorWheel() plugged in for color values

  while (digitalRead(Motion) == HIGH){
    // do nothing (wait for pin to go low again)
  }
 
} //closing curly of the “loop()” function

Return to “Plumduino Basics”

Who is online

Users browsing this forum: No registered users and 1 guest