Sensor Light Box

by emma_leung in Circuits > Arduino

305 Views, 0 Favorites, 0 Comments

Sensor Light Box

IMG_4409.JPG

When you walk close to the light box it lights up. The main use of this is to remind people which are leaving their home. Parents could leave notes to their children to remind them. The box would light up making whoever leaving the home would pay attention to it.

Prepare the Components

Screen Shot 2019-06-03 at 3.35.24 PM.png
IMG_0572.JPG

1. Ultrasonic sensor

2. Bread Board

3. 1 kohm Resistor

4. Jumpers

5. White LED light

6. Plastic Transparent Board

7. Card Board Box ( 20x30x11)

8. Hot Glue Gun

9. Wipeable neon marker

Connect the Components

Screen Shot 2019-06-03 at 3.31.27 PM.png
IMG_2314.JPG

Connect the wires as the pictures has shown.

Make the Outer

IMG_1952.JPG
IMG_5793.JPG
IMG_4409.JPG

1. Dig two holes on the box

2. Cut the top of the box for the plastic to fit in

3. Glue the plastic to secure

4. Place the Components in the box.

Write the Code

#define trigPin 13

#define echoPin 12

#define led 11

void setup()

{ Serial.begin (9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(led, OUTPUT);

}

void loop()

{ long duration, distance;

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;

if (distance < 10)

{ digitalWrite(led,HIGH);

}

else {

digitalWrite(led,LOW);

}

Serial.print(distance);

Serial.println(" cm");

delay(500);

}

Upload and Run

Arduino light box