Wednesday, November 27, 2019

Distance Measuring Using UltraSonic Sensor and Arduino


In this project we are going to measure distance using ultrasonic sensor and the measured distance value will be displayed on computer screen.

We will be using Processing 3 software to display the distance on the compter screen.


For this project we need
  • Arduino uno
  • Ultrasonic sensor HC-SR04
  • BreadBoard jumper wires

Theory Behind Measuring Distance

The Sensor works on the phenomenon of Echo of sound.

In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled.

As speed of sound is 340 m/s (0.034 cm/us) we can calcute the received echo signal pulse duration and hence the formula for calculating distance is


Distance = (Echo pulse Duration) * 0.034 / 2


Dividing by two is done because the same wave is transmitted and received back

Connection Diagram


Arduino and Processing Code

Pocket Size CO (carbon Monoxide) Detector



In this project we will be making a pocket sized CO detector which is used to detect Carbon monoxide in air our goal was to make this device portable and which fits in pocket size.
Now a days we are facing problem of air Pollution due to industrialization every day harmful gases are released into air and even vehicles releasing harmful Carbon monoxide.
So we thought of making this project which we could carry anywhere and check the air condition whether it is clean or polluted.
We have build this project in a affordable budget,it costed around 12 USD.Parts Used


Parts used
  • Arduino Pro Mini
  • Oled 128*96 Display
  • MQ9 Carbon Monoxide Sensor
  • Li polymer battery
  • Li polymer battery charger (Extracted from a old Powerbank)
  • led 2mm
  • Slide Switch
  • Screws
  • Cardboard
  • Masking tape


Circuit Diagram


Arduino Code

Click on the link below to download the code:


Final Output



Social handle links


Connect Lcd 16x2 to Arduino with just 4 wires !!!!!!

Normally connecting a LCD 16x2 to  arduino we require around 14 pins (using in 4 bit mode which is by default in arduino example sketch) ...