Sensor Light Box
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
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
Connect the wires as the pictures has shown.
Make the Outer
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);
}