Here is a very simple college project using Arduino and Accelerometer. Spirit Level (also called Level Bottle) is a tool which is used to see whether the surface is perfectly horizontal or not, this tool is used by plumbers and carpenters and some hobbyist to make perfectly level surfaceIn this project I present a Digital Version of this Spirit level.A typical analog one looks like this.
Interface Devices :
1. Sensor :
Now the most important part of this project is to measure the tilt of our board w.r.t to ground level. For this we use an Inertial Measurement Unit Sensor called Accelerometer.
The same sensor is used in our smart phone to detect the orientation of our phone, that’s why when we tilt the phone the screen changes from portrait to landscape.
Now there are many types of accelerometer sensor whose working principles, Axis & Interfacing methods are different (like I2C, SPI, Analog).
And obviously the simplest of all sensors is the one which gives out analog values and we can feed these analog values to the ADC and get the readings in our microcontroller.
In this project I have used ADXl 335 Accelerometer sensor.
ADXL 335 is a 3-DOF(Degrees of Freedom) Accelerometer
3-DOF:Because it gives measure of tilt along 3 axis.
In this project we are making only 1 axis tilt sensor, so we require connecting only Y pin to Arduino’s ADC input.
Here’s the connection.
Note: Vcc and gnd are connected to Analog pin 5 &4 respectively, and in the program we will set pin 5 & 4 as High and Low which will serve as Vcc and gnd
2. Display :
This project uses a 16×2 character LCD to show a dramatic air bubble as in Air Bubble Spirit Level available in hardware stores.
Smoothing Example of Arduino
Now directly using sensor data is not recommended because it gives very noisy output. So here I found something very interesting in Arduino IDE’s inbuilt examples. It is called as smoothing which can be opened from here.
It is a very interesting example because it gives a very clean data out of your noisy sensor (like Accelerometer, its too much noisy) by filtering out high frequency noise.
After careful study of the code I found out that it actually calculates the moving average from sensor data which is a type of Finite Impulse Response Low Pass Filter.
It actually samples some predefined number of sensor readings and then puts it in series in a subset. Then the subset is modified by “shifting forward”; that is, excluding the first number of the series and including the next number following the original subset in the series. This creates a new subset of numbers, which is averaged. This process is repeated over the entire data series.
You can change the no of elements you want in the series by changing the number in this line of smoothing code.
const int numReadings = 10 ;
Too high number will result in slow response
So I tinkered with the smoothing example and added code for LCD and that’s all.
So all we do is set cursor on our LCD according to the sensor data and print a special character (like air bubble).
Project Source Code
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.