Introduction: Arduino Ultrasonic Security System

HEY! You're looking at my project for the Computer Engineering Final. This circuit, controlled by a switch, is set up and coded to read and alert the distance of a nearby object.

With a flick of a switch, the system comes to life, allowing the distance sensor to inform the distance with a message. The RGB LED outputs a certain colour according to safety protocol while the 7 Segment Display assists in understanding the displayed colours.

With that little insight into this project, let's go ahead and work through the steps of this build.

Step 1: Required Components

This is a list of the parts we need to complete this build:

1 x Arduino Uno

1 x Breadboard

1 x Dip Switch

1 x RGB Common Anode (CA)

1 x Distance Sensor (HC-SR04)

1 x 7 Segment Display Common Anode (CA)

3 x 330 ohm resistors

1 x 10K ohm resistor

Coloured jumper wires (Male to Male)

Apparently, you can find them all on Amazon by the way. :)

Step 2: Assembly of Parts

Now that we have all the necessary parts to finish this circuit, the above pictures should give you an idea of how to wire them up. The images were taken from the circuit being done online using Tinkercad. (But between you and me, it works better with real-life components.)

We're wiring just one switch of the Dip Switch to power and using a 10K ohm resistor for ground. We are connecting it to digital pin 2. The RGB is a common anode, so we are using a 330-ohm resistor to power that and the other legs are connected to PWM pins (3, 5, 6). The Distance Sensor is connected to power and ground while "trig" is connected to pin 9 and "echo" is connected to an analog pin (A0).

The 7 Segment Display is a common anode, so we have connected its common pins to power using 330-ohm resistors. The 7 pins (excluding the DP pin) are connected to digital pins on the Arduino. We are also connecting the top and bottom rails of the breadbaord for both power and ground. This way the current from the Arudino flows through the whole breadboard now.

Step 3: Wiring

After you got an idea on how the wiring works, we are ready to wire it ourselves with the actual parts. The images above provide a design of how it should look, although the wires are kind of all over the place.

Make sure that when you are wiring, there is no copper seen to the eye. You can colour code to better understand which wire is connecting what. I like to use red wires for power and black for ground.

The rest are connecting the components to digital or analog pins. You can also see how the wires are connected to pins in the image above.

Step 4: The Code

Now that we're all wired up, we can upload the code. The given code is easy to follow with comments to understand certain parts of the build.

The code allows the switch to control the passing current of the circuit to turn the system on and off. When the switch flips on, the 7 Segment Display is coded to display certain patterns for a certain distance. The RGB LED displays colours for the read distance. The distance sensor also becomes active sending signals to read the distance.

This code is only set for up to 10 inches of distance just for the purpose of displaying the project while it's working. Anything above 10 inches, allows Serial Monitor to print another message indicating that the object is out of boundaries. The Serial Monitor continues to print messages letting us know the distance, system status, and alerts.

Step 5: How It Works

Click the link below!

The video here, explains and shows how the circuit actually works in real life. It gives you an idea of how the system actually runs. Go ahead and click the video.

https://drive.google.com/file/d/19cUkGrq8sw2baErdY...

Thank for you taking a look at my project. It was a lot of fun putting this together.

Good luck with your projects!