Arduino Cardboard Gun(RangeFinder &Tachometer)

by Bilal20 in Circuits > Arduino

878 Views, 0 Favorites, 0 Comments

Arduino Cardboard Gun(RangeFinder &Tachometer)

E96D995D-667E-4248-B3B1-9EBF9AEF834C.jpeg
A271FBF1-B7C6-43A3-A5B0-B97ACB8306ED.jpeg
28EF722B-0030-4808-BB27-E5506FCFB832.jpeg
1B89D405-F075-4C2B-A07D-C1BA638488F7.jpeg

Wouldn't be awesome to be able to measure distance while sitting comfortably on the Couch?Instead of having to use tradional tape? So today I’m going to make an arduino gun that is capable of non-contact measurement of distances from 2cm to 400cm with an accuracy of 0.3cm and also measure the revolutions per minute of a rotating body(RPM) using an ultrasonic sensor(HC-SR04) and an infrared sensor respectively. Initially, I wanted to make it capable of measuring the speed of any moving object using two additional IR sensors but I’m out of supplies due to the current pandemic. So I’m only going to use what I have. If you have them, then you can add to the gun. Here’s a link on how to do that.

How It Works

1B072CDF-364A-4C2C-9A96-F7D38C02A7A2.png
78D035D0-122A-49BF-893D-BD27F8B16374.png

Ultrasonic sensors work by emitting sound which travels through the air and if there is an object on its path, it will bounce back to the module. Considering the travel time, you can calculate the distance since we already the speed of sound (340m/s) using the formula: distance= velocity *time. The IR sensor purpose in this project is for object detection.IR sensor has two main parts.IR transmitter and IR receiver. The transmitter transmits IR waves and if there is an object, the transmitted wave is reflected by the object which in turn, the receiver picks-up the wave whereas if there is no object in front of the sensor, the transmitted wave is not received by the receiver and then the IR Module generates an output or pulse which is detected by the Arduino when we press the trigger button.It counts continuously for 5 seconds. So let’s start building.

<

Supplies

2A519209-69E6-4469-B9F0-0286CB8CA100.jpeg
A1EFCFAE-F336-452B-83B1-B0B7FFF11056.jpeg

MATERIALS
1. Arduino Uno (any arduino will work)

2. HC-SR04 Ultrasonic sensor

3. Arduino IR sensor

4. 16*2 LCD display module(12C)

5. Buzzer

6. 9V battery and connector

7. Perf board (optional)

8. A Pushbutton

9. Tactile switch *1

10. Slide switch *1

11. LED *2 (Preferably different colours)

12. 220ohms resistor *2

13. 10k resistor *2

14. Arduino pin headers

15. Jumper wires

TOOLS

1. Hot glue

2. Super glue(optional)

3. Soldering Iron and solder

4. X-acto knife

5. Drill(optional)

Making the Body

75FFC589-AF20-4A64-BD69-A1CB2C127099.jpeg
1800B2ED-79C0-4B5A-8937-20EDFDA5195A.jpeg
08DAC635-D49E-4631-A476-284FC0E0617B.jpeg
F051D9DF-CE36-4B26-BEEB-963C5AF86DF9.jpeg
57E29E3F-3F66-4D1D-8822-FB24EBD65660.jpeg
BFBD6818-C16B-48BB-B11E-D775447A08A9.jpeg
B91C8D8E-0556-4B02-A013-81E818C0496D.jpeg
90EEE50F-CEF0-4B50-B193-DFF9E46B8B56.jpeg
A28290C1-0828-4C6E-9076-6027B5E31676.jpeg
14F704C5-DCB6-4CBE-9243-52A76B1BF8CA.jpeg
4AFE9165-C1C8-429E-8DCD-CAAE4196D9C9.jpeg
B9CEAC8A-5AB2-42A4-911C-B2D97CAB777D.jpeg
88E45C38-D4A3-431D-A86A-A7E3E86E02A8.jpeg
13511CC2-65AC-48B7-9E55-A582820C1653.jpeg

1. Print out the template provided, glue it to the sheet of cardboard and then cut out the shapes.

2. Cut-out the buzzer hole, status led, power led, ultrasonic sensor, IR sensor holes and the LCD display space.

3. Use a ruler to bend all the straight lines inward and glue each section together. Do not glue the display section, handle and roof cover to the rest the gun. Glue the ultrasonic sensor and the infrared sensor into their various holes.

4. Cut-out a 3cm wide cardboard strip and cover the front and back of the handle. Glue a pushbutton to the front of the handle and run the wires through the back of the handle.

Electronics Setup

F868EE5F-89ED-4DC2-B307-52762FD55A6F.jpeg
717915EE-7779-4D1F-B7E8-375FD448FF85.jpeg
70268114-4D33-4EF8-9F3C-2A78095A28EA.jpeg
FBB2EDCD-8516-4428-A644-E44C2CB1B44C.jpeg

IR SENSOR

I used the wires from a network cable since I’m out of jumper wires, then soldered the wires to a small piece of perf board which is then soldered to the three pins of the sensor.

ULTRASONIC SENSOR

I used an old connector which I inserted into the pins of the sensor.

LCD DISPLAY

I bent the pins of the LCD display so that they are straight. I then repeated the same setup as with the IR sensor.

LEDs

A 220ohms resistor is to each of the led’s cathode lead.

Circuit

84E47B89-CA81-4F84-8AAC-87D141C32C56.jpeg
1B072E34-D1DA-4C6D-AE42-E6327FD60C26.jpeg
66960D37-8153-445A-B592-30B54B84D3B4.jpeg
B25B139D-73E0-4FF4-AD9F-4FAD17D78F9C.jpeg
A515E7AC-61E1-49BF-93D6-23E4BC1D768F.jpeg

You can choose to make the circuit on a mini breadboard or preferably on a perf board. Either way, it’s up to you to decide.

Note: The arduino is powered though its VIN pin. Also mine is mounted upside down.

HERE’STHE CONNECTIONS

POWER LED

Anode----Arduino Pin 8

Cathode---220ohm resistor----Ground

STATUS LED

Anode----Arduino Pin 9

Cathode---220ohm resistor----Ground

BUZZER

Positive---Arduino Pin 11

Negative---Ground

IR SENSOR

VCC---Arduino 5V

GND---Ground

OUT---Arduino Pin 5

HC-SR04

VCC---Arduino 5V

GND---Ground

TRIG---Arduino Pin 7

ECHO---Arduino Pin 6

LCD DISPLAY

VCC---Arduino 5V

GND--- Ground

SDA---Arduino Pin A4 (analog pin)

SCL---Arduino Pin A5 (analog pin)

Trigger Button

First Leg -- ----Arduino 5V

Second Leg ---10k resistor (first leg in parallel with)---Arduino Pin 10

(Other leg of resistor to ground)

SPDT SLIDE SWITCH

Center Leg -------Arduino 5V

Left Leg -----10k resistor (first leg in parallel with)---Arduino Pin 13

(Other leg of resistor to ground)

Arduino VIN pin------First leg of pushbutton

Second leg of pushbutton-----+Ve of battery

Arduino GND pin---Battery -Ve and ground rail

Final Assembly

8373E3F0-605F-420B-8335-8D0FEC524B20.jpeg
0FB51759-D0E1-4529-B922-BE2AB7EF08D0.jpeg
9519893B-828B-4C91-9932-DE8AE7C4822B.jpeg
94EEC9BB-E1D1-4620-BE9C-9696D7CF84E6.jpeg
FA10F895-2BA6-4B56-8469-E650CFB6F4B0.jpeg
4A7D7F41-3062-4D87-8483-988103D1A34E.jpeg
FB231017-B8E6-4CBE-9883-E64736296F9C.jpeg
EC1D997D-43DC-4D38-83AA-811A311AD6BA.jpeg
32AEFDE5-D46A-4EED-BDC9-05879A38EDEB.jpeg
0641A1A5-240A-464F-B4D2-4B7C8F825573.jpeg

Start by inserting the LEDs into their holes, followed by the buzzer, the two switches and then the LCD display into the display section. Pass the trigger button’s wire through the hole at the bottom of the display section. Glue the sensor module to the front of the gun. Glue the display section to the gun’s main body and then attach the handle underneath. Hold the rectangular roof cover with tape to the gun. This will be an access door. Now your RangeFinder/Tachometer is ready for use. Decorate as you wish.

Code

Its a good idea to know what the code does before you start to program it. This can save you alot of headache.

Also, install the liquid crystal display library if your LCD has a 12C module. Click here to download

Here’s what the code does

1. When you turn on the gun, the power led turns on and the gun plays a beep sound for less than a second (the power led can be powered directly from the battery, but I decided to power mine from the arduino. This allows the led to be controlled)

2. Once the gun is powered up, youll have to move the slide switch either left or right to select the mode you want. Once that is done, it will display “Please Trigger button to start”. After pressing the button, the reading/measurement should start. With each button press, the status led with blink and the buzzer will beep.

Downloads

TIPS

DE7D27C1-A013-401E-8E00-572C182A4B75.jpeg
89ABEC94-7F67-42AA-8392-F8D94568969F.jpeg
9E2FE73B-3133-4DC5-908D-3EF4719252E8.jpeg

1. When soldering the pin headers to the perf board, first insert the pin headers into the arduino pins you are using and then lower the board on top of the board with the copper side of the perf board facing up. Solder the headers in place.

2. Make a small access hole on the front side of the gun. This will be used to adjust the sensitivity of the IR sensor using a screwdriver.

3. If the code doesn’t work,

· First check your connections (especially if you used a breadboard).

· If using an old battery, replace it.

· If still doesn’t work, comment down below for assistance.

HAVE FUN WHILE STAYING AT HOME!