Final Project

week14-display.jpg

For my final project, I designed a foldable lamp that can change color depending on the degree to which it is compressed. See more about the conception of this project idea here

Lamp shade

I used a similar design to that from last week for the lamp shade; however, I shortened the number of creases. The design includes mountain creases (red), valley creases (blue), and cuts (green).

Insert an image like this

With the help of Alfonso, I cut my lamp shade using the Zund cutter. I also chose to use paper this time, as it would be easier to fold and more easily compressible.

Insert an image like this

Electronics

To detect the degree of compression, I decided to use a sonar sensor to detect changes in distance. I designed a new board for the sonar sensor.

Insert an image like this

Additionally, I designed a board for the RGB LED lights.

Insert an image like this

Luckily, I had routed enough pints from the ESP32 board I designed during Week 10, so I reused that board.

Programming

Then, I programmed my board to have the LEDs light up as different colors depending on the distance measured in the sonar sensor.

 1const int trigPin = 16;
 2const int echoPin = 4;
 3const int blueOut = 19;
 4const int greenOut = 18;
 5const int redOut = 5;
 6
 7const int red_thresh = 8;
 8const int green_thresh = 15;
 9const int blue_thresh = 25;
10
11long duration;
12int distance;
13void setup() {
14  pinMode(trigPin, OUTPUT);
15  pinMode(echoPin, INPUT); 
16  Serial.begin(9600);
17  
18  pinMode(redOut, OUTPUT);
19  pinMode(greenOut, OUTPUT);
20  pinMode(blueOut, OUTPUT);
21
22  digitalWrite(redOut,LOW);
23  digitalWrite(greenOut,LOW);
24  digitalWrite(blueOut,LOW);
25}
26
27void loop() {
28  digitalWrite(trigPin, LOW);
29  delayMicroseconds(2);
30  digitalWrite(trigPin, HIGH);
31  delayMicroseconds(10);
32  digitalWrite(trigPin, LOW);
33  duration = pulseIn(echoPin, HIGH);
34  distance = duration * 0.034 / 2;
35
36  if (distance < red_thresh) {
37  digitalWrite(redOut,HIGH);
38  digitalWrite(greenOut,LOW);
39  digitalWrite(blueOut,LOW);
40} else if (distance < green_thresh) {
41  digitalWrite(greenOut,HIGH);
42  digitalWrite(blueOut,LOW);
43  digitalWrite(redOut,LOW);
44} else if (distance < blue_thresh){
45  digitalWrite(blueOut,HIGH);
46  digitalWrite(redOut,LOW);
47  digitalWrite(greenOut,LOW);
48}
49}

Along the way, I tested the board and the LED light strip, and they both worked very well!

Insert an image like this

Packaging

Finally, I designed the top and base of my lamp using Onshape.

Insert an image like this

After that, I used the laser cutter to cut my pieces from pieces of Delrin that I acquired from Miana.

Insert an image like this

With all my pieces cut, I assembled my circuits and the base of my structure.

Insert an image like this

Finally, I reprogrammed my board to be suitable for the distances in the final product. Overall, the final product looks very nice!

Insert an image like this

The sonar sensor is not as precise because it is affected by scattering effects as it sits inside my lamp. Nevertheless, I think the project was very successful since it does react to changes in distance. Future features to add include

  • Communicating with the lamp wirelessly to tun the lamp on and off
  • Filters to remove the scattering effects
The Latest