This is the single-project presentation page. Use this space to present the project as a long-form post: motivation, context, design decisions, and outcomes. Below are sections where you can paste detailed write-ups, diagrams, code snippets, and images.

Overview

Dorm closets are dark. I wanted to create a small, circular, portable motion-activated light that can be stuck to the inside of a closet door via adhesive strips, and turn on whenver a ToF sensor is activities (i.e. whenever the door is opened).

System Architecture

The final product will mainly consist of a ToF sensor, an LED, and a microcontroller. When the ToF sensor’s readings reach a certain threshold, the LED will turn on. The product will be contained in a cylindrical plastic shell.

Implementation Details

I started with a simple breadboard prototype using an ultrasonic sensor, switch, and LED. The microcontroller would read the ultrasonic sensor's output and when it exceeded a certain threshold, it would turn on the LED. I eventually chose to switch from an ultrasonic sensor to a TOF sensor because of the smaller footprint. The breadboard prototype also assumes the microcontroller is externally powered, which would not be the case under real use conditions. This prototype allowed me to plan out the logic of the design of the actual device.

Implementation image 1
Prototype breadboard design
Implementation image 2
Draft schematic for the PCB

Once I was happy with the breadboard prototype, I wanted to move on to a PCB design. I had no prior experience with PCB design so I used the tutorials available on the HIVE Makerspace YouTube channel to learn the software itself and the design process. I created a rough draft schematic and learned about footprints and the different layers and processes involved in PCB design.

Here's the Arduino code I used for the initial prototype with the ultrasonic sensor. It reads distance measurements and controls the LED based on the detected proximity:

// 
int ledPin = A0;
int uTrig = 6;
int uEcho = 7;

long duration;
int distance;

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(uTrig, OUTPUT);
  pinMode(uEcho, INPUT);
  Serial.begin(9600);
}

void loop()
{

  digitalWrite(uTrig, LOW);
  delayMicroseconds(2);

  // Send a 10 microsecond pulse to trigger the sensor
  digitalWrite(uTrig, HIGH);
  delayMicroseconds(10);
  digitalWrite(uTrig, LOW);

  // Read the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(uEcho, HIGH);

  // Calculate the distance
  distance = duration * 0.0343 / 2;

  // Print the distance on the Serial Monitor
  Serial.print("Distance: ");
  Serial.println(distance);
  delay(100); // Wait a bit before the next reading
  
  if (distance == 0){
  	digitalWrite(ledPin, LOW);
  } else if (distance <= 100){
  	digitalWrite(ledPin, HIGH);
  } else{
    digitalWrite(ledPin, LOW);
  }
}

Next Steps

I'm not yet done with the project. I want to redo the schematic and make the wiring more organized. I would also like to finish creating the footprint for the PCB and hopefully print it soon! Ideally, the PCB is round to match the shape of the device itself. Additionally, I would like to create a custom CAD model and 3D print a case to house the internals.

Skills Learned

I learned about Arduino programming; PCB design; CAD modeling; Reading and creating schematics; and finding and interpreting datasheets.

← Back to home