Introduction: Simple LED Light Garage Sensor
This device ensures a safe distance for parking and uses an ultrasonic sensor combined with an LED strip to make a sensor that ensures a safe distance between the car and the wall. When the car is too close to the wall, the green LED will illuminate as a warning signal.
Supplies
Materials you need to make the Simple LED Light Garage Sensor :
- Arduino Leonardo ×1 (OEM, include pins)
- Leonardo wire ×1 (1.5m)
- Bread Board ×1 (EIC-1102)
- Solderless Breadboard Jumper Cables × 10 (8mm)
- Male-to-Female Jumper Ribbon Cables × 20 (20P, 2.54 multicolor 30cm )
- Arduino LED × 10 (5mm, all green LED)
- Ultrasonic Sensor HC SR04 Module for Arduino × 1
- Resister × 10 (10pcs,1/4W, 82Ω)
- Wood bottom plate × 1(Length 18mm, Width 12mm, Height 3mm)
- White translucent box × 1
- Electrical insulation tape × 1
- Box cutter × 1
Step 1: Building the Box
There are many ways to make a white translucent box. However, I found that this kind of premade box is available on the market, and it's also much more aesthetic, so I purchase one from Muji.
In case you really want to make this box yourself, I have recorded the length and width of the box in the design layout on the picture above. You can use the white translucent plastic or acrylic sheet to cut and glue pieces together as the outer packaging.
To add a little decoration, I cut out a smiley face from a sheet of black thin cardboard and paste it on the inner side of the box so that when the green LED lighted up, there will be a smiley face on the lighted box.
Step 2: Electronics-Setting Up the Circuits
Connect each LED light bulbs to positive(VCC) and negative(GND) ends, do the same to the ultrasonic wave sensor and plug TRIG to D6 and ECHO to D7. Prolong the wire that connects the ultrasonic wave sensor to the breadboard and Arduino Leonardo by plugging the Male-to-Female Jumper Ribbon Cables.
Step 3: Arduino Leonardo Coding
Coding
The code of this Simple LED Garage Sensor is shown below, descriptions are remarked within the coding.
<p>int ardublockUltrasonicSensorCodeAutoGeneratedReturnCM(int trigPin, int echoPin)<br>{ long duration; pinMode(trigPin, OUTPUT);//this is the trigger pin pinMode(echoPin, INPUT);// this is the echo pin digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(20); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); duration = duration / 59; if ((duration < 2) || (duration > 300)) return false; return duration; }</p><p>void setup() { digitalWrite( 6 , LOW );</p><p> pinMode( 13 , OUTPUT);//These are all the 10 LED light bulbs pinMode( 12 , OUTPUT); //These are all the 10 LED light bulbs pinMode( 11 , OUTPUT);//These are all the 10 LED light bulbs pinMode( 10 , OUTPUT);//These are all the 10 LED light bulbs pinMode( 9 , OUTPUT);//These are all the 10 LED light bulbs pinMode( 8 , OUTPUT);//These are all the 10 LED light bulbs pinMode( 5 , OUTPUT);//These are all the 10 LED light bulbs pinMode( 4 , OUTPUT);//These are all the 10 LED light bulbs pinMode( 3 , OUTPUT);//These are all the 10 LED light bulbs pinMode( 2 , OUTPUT);//These are all the 10 LED light bulbs }</p><p>void loop() { if (( ( ardublockUltrasonicSensorCodeAutoGeneratedReturnCM( 6 , 7 ) ) < ( 60.0 ) ))//When the coming object in front of the ultrasonic sensor locates in a distance that is lower than 60 { digitalWrite( 13 , HIGH );//then, the 10 LED light bulbs will illuminate as a warning digitalWrite( 12 , HIGH );//this light bulb will illuminate digitalWrite( 11 , HIGH );//this light bulb will illuminate digitalWrite( 10 , HIGH );//this light bulb will illuminate digitalWrite( 9 , HIGH );//this light bulb will illuminate digitalWrite( 8 , HIGH );//this light bulb will illuminate digitalWrite( 5 , HIGH );//this light bulb will illuminate digitalWrite( 4 , HIGH );//this light bulb will illuminate digitalWrite( 3 , HIGH );//this light bulb will illuminate digitalWrite( 2 , HIGH );//this light bulb will illuminate delay( 1000.0 );//the sensor will delay for one second } else//if the coming object in front of the ultrasonic sensor locates in a distance that is furthur than 60 centimeters... { digitalWrite( 13 , LOW );//then, the 10 LED light bulbs will not illuminate as a warning digitalWrite( 12 , LOW );//this light bulb will not illuminate digitalWrite( 11 , LOW );//this light bulb will not illuminate digitalWrite( 10 , LOW );//this light bulb will not illuminate digitalWrite( 9 , LOW );//this light bulb will not illuminate digitalWrite( 8 , LOW );//this light bulb will not illuminate digitalWrite( 5 , LOW );//this light bulb will not illuminate digitalWrite( 4 , LOW );//this light bulb will not illuminate digitalWrite( 3 , LOW );//this light bulb will not illuminate digitalWrite( 2 , LOW );//this light bulb will not illuminate delay( 1000.0 );//the sensor will delay for one second }//Date 2019/06/03 }//author Charlene Chang</p>
Step 4: Ensuring the Circuit and Your Code
Check if the code could work with the Arduino Leonardo. Also, wrap your wires with the insulation tape to ensure that the wire won't fall off or disconnect while operating.
Step 5: Assemble That Arduino Leonardo Stick With the Box Tightly
Tape your wood bottom plate that has the Arduino Leonardo stuck on with insulation tape to make sure that the position of every device is all stable in place. This way, your wood bottom plate will not accidentally plug off some wire from the breadboard while moving around in the box.