Xuan-LAZY LAMP

Is this situation ever freak you out that when you are ready to bed, after turning off the light, you cannot see anything. Has it ever happened to you that when you are chilling on your bed, somehow you are too sleepy to get up turn off the switch?

If so, let’s make a lazzzie lamp which can detective the motion( by a motion sensor) and volume(microphone) of your room. So if you are getting sleepy, and stopping moving or making any sound, the lamp will get dimmer till turn off.

IMG_5917IMG_5934

Want to build your own one? Let’s go.(check the Instructable here)

Tools:

  • Wire strippers;
  • Soldering iron;
  • Lathe;
  • Laser cutter;
  • Table saw;
  • Blend saw;
  • (Or 600$ + 3D printing);

Materials:

  • Arduino Uno;
  • Motion sensor;
  • Microphone:
  • Breadboard:
  • Acrylic;
  • Breadboard wires;
  • Solder;
  • Dotstar LED stripper

Step 1: Soldering and Connecting Circuit

Step 2: Coding

#include
#include

#define NUMPIXELS 20 // Number of LEDs in strip

// Here’s how to control the LEDs from any two pins:
#define DATAPIN 13
#define CLOCKPIN 12
Adafruit_DotStar strip = Adafruit_DotStar(
NUMPIXELS, DATAPIN, CLOCKPIN);

int brightness = 255; // rudamentary brightness value output to the dotstars (0-255)
const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;

int micrphonePin = A0; // Analog input pin that the microphone is attached to
int sensorValue = 0; // value read from the microphone (0-1024)

int inputMotion = 11; // Digital input pin that the motion sensor is attached to
int motionValue = 0;

int fadeAmount = 4;
int plus = 10;
int line = 400;

unsigned int signalMax = 0;
unsigned int signalMin = 1024;

void setup() {

pinMode (inputMotion, INPUT); // digital pins can be either inputs or outputs so we have to define which it will be this time

strip.begin(); // Initialize pins for output
strip.show(); // Turn all LEDs off ASAP

// initialize serial communications at 9600 bps:
Serial.begin(9600);
}

void loop()
{
int sample = soundSample();

motionValue = digitalRead(inputMotion);

Serial.print(“\t microphone sample = ” );
Serial.print(sample);
Serial.print(“\t motion = ” );
Serial.print(motionValue);
Serial.print(“\t brightness = “);
Serial.println(brightness);

if(brightness >0){
if(sample >= line || motionValue == 1){
brightness = brightness + plus;
if(brightness>=255)
{
brightness=255;
}
}

if(sample < line && motionValue == 0){
brightness = brightness – fadeAmount;
}
}

fillAll(strip.Color(brightness, brightness, brightness));
if(brightness<50)
{
delay(100);
}
delay(50);
}

int soundSample()
{
unsigned long startMillis= millis(); // Start of sample window
unsigned int peakToPeak = 0; // peak-to-peak level

// collect data for 50 mS
while (millis() – startMillis < sampleWindow)
{
sample = analogRead(micrphonePin);
if (sample < 1024) // toss out spurious readings { if (sample > signalMax)
{
signalMax = sample; // save just the max levels
}
else if (sample < signalMin)
{
signalMin = sample; // save just the min levels
}
}
}
peakToPeak = signalMax – signalMin; // max – min = peak-peak amplitude
return sample;
}

void fillAll(uint32_t c)
{
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
}

strip.show();
}

Step 3: Making the shape of the lamp

1.Laser cut acrylic

  1. Stripper: the width of the stripper is a little bit wider than the LED stripper,  so that you can glue them on later.
  2. Circles for the bottom.IMG_4405

2.Build dowels

  1. Glue wood sheets together overnight;IMG_4245
  2. Use table saw to cut the cuboid;IMG_4259
  3. Use lathe to make your own dowels;
  4. use blend saw to cut them in pieces;IMG_4274

3. Bend your acrylic.

  1. Use tape glue the pieces together and fix it with clamps;
  2. Heat the acrylic;IMG_4298
  3. Bend it;
  4. Cool down;IMG_4333
  5. Untaped
  6. A little bit sanding

4. Glue

Steps 4: Assembled each part

IMG_4438

 

%d bloggers like this: