Skip to content

Final Project

For my final project, I thought of something I needed, and when I looked around my room, I found that I needed a bedside lamp for my sleep. The special thing about this light is that it will work automatically by sensing the lightness of the room.

Design

At the beginning, I designed the structure of the lamp by using MakerCase and Fusion 360. By using MakerCase, I chose the shape and dimensions, while on Fusion 360 I designed the pattern, which is a square pattern.

Material

For the material, I chose to use 6mm thick acrylic to have a pretty cut shape, as well as a strong and heavy structure to prevent any crashes. I painted it black to match any place. To diffuse the light, I used 3mm thick milky white acrylic.

Fabrication

To fabricate the lamp, I used a laser cutting machine, and I also used glue to connect all the pieces with each other.

Electronics

Moving to the electronic part, I used an Adafruit Feather to control the system. I used an addressable RGB LED and a phototransistor (LDR sensor). The lamp has three different levels of brightness, and the sensor will read the surrounding lightness and change the level of brightness based on that.

Code

// Include the necessary library
#include <Adafruit_NeoPixel.h>

// Define the pin for the LED strip
#define LED_PIN 6

// Define the number of LEDs in the strip
#define NUM_LEDS 60

// Define the pin for the light sensor
#define LIGHT_SENSOR_PIN A0

// Define the brightness levels
#define BRIGHT_LEVEL 255
#define MID_BRIGHT_LEVEL 100
#define DARK_LEVEL 0

// Create a NeoPixel object
Adafruit_NeoPixel strip(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  // Initialize the NeoPixel strip
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  // Read the value from the light sensor
  int lightSensorValue = analogRead(LIGHT_SENSOR_PIN);
Serial.println(lightSensorValue);
  // Adjust the brightness based on the light sensor value
  if (lightSensorValue > 800) {
    // Bright outside, turn off the LEDs
    adjustBrightness(DARK_LEVEL);
  } else if (lightSensorValue > 500) {
    // Somewhat dim outside, set to mid brightness
    adjustBrightness(MID_BRIGHT_LEVEL);
  } else {
    // Dark outside, set to high brightness
    adjustBrightness(BRIGHT_LEVEL);
  }

  // Delay for a short time
  delay(100);
}

void adjustBrightness(uint8_t brightness) {
  // Set the brightness of all LEDs
  for (int i = 0; i < NUM_LEDS; i++) {
    strip.setPixelColor(i, strip.Color( brightness,  brightness, brightness));
  }
  strip.setBrightness(brightness);
  strip.show();
}

The Project

Fusion Design

2D Design


Last update: August 5, 2024