# Smart Bed Light

## Made by Hongxun Jin, Ariel Yu and xinyixu

By connecting to the user's digital devices like kindle, laptop, tablet & phone, the light could adjust the brightness and color temperature based on the user's device activation and reading habits.

0

### Stakeholder

Our proprietor is an MBA student from Tepper Business School. He is busy during the daytime and usually gets home between evening and night. Usually, after getting home, he works on his laptop for a bit to finish his assignments, reports, and other tasks. Afterward, he enjoys his night relaxing by reading leisure books on Kindle after taking a refreshing hot shower. However, since he is currently living in a rental apartment, he is not satisfied with the current brightness of his apartment, especially the one in his bedroom, where he mostly stays for no matter doing work or relaxing. With only one light source on the ceiling, his room is quite dim at night.

0

0

### Idea Concept

To solve the problem that bothers our proprietor, we need to tackle with the brightness issue in his bedroom. By connecting to the user's digital devices like kindle, laptop, tablet & phone, the light could adjust the brightness and color temperature based on the user's device activation and reading habits.

0

### Prototype

0
Smart Bed Light

0
``````// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
#include <math.h>

#include "Particle.h"
#include "neopixel.h"
SYSTEM_MODE(AUTOMATIC);

// IMPORTANT: Set pixel COUNT, PIN and TYPE WS2812B E357163
#define PIXEL_PIN D2
#define PIXEL_COUNT 7
#define PIXEL_TYPE WS2812B

int conditionPin = A1;
int conditionVal = 0;

// Prototypes for local build, ok to leave in for Build IDE
void rainbow(uint8_t wait);
uint32_t Wheel(byte WheelPos);

int pixel_position = 0;
int startTime = -1;
int checkTime1 = 5000 ;
int checkTime2 = 10000 ;
int checkTime3 = 5000 ;
unsigned long currentTime = -1;

void setup()
{
Serial.begin(9600);
Particle.variable( "condition", conditionVal );

strip.begin();
strip.show(); // Initialize all pixels to 'off'
delay(1000);
startTime = startTime + millis();
}

void loop()
{
//rainbow(20);
int x;
Serial.println(conditionVal);
x = map(conditionVal, 0, 4096, 0, 255);
uint32_t c = strip.Color(255-x, 255-x, x);

// three states color change
if (x > 170) { c = strip.Color(0, 0, 255); } // blue
else if (x < 90) { c = strip.Color(255, 255, 0); } // yellow
else { c = strip.Color(255, 255, 255); }  // white

for (int i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
}
strip.setBrightness(255);
strip.show();

}``````
Click to Expand