First of all, it is important to understand how the Arduino Accelerometer sensor works. The Accelerometer sensor is measuring the change in gravity in 3 dimensions which are X, Y, and Z. Each axis has a string then it measures how stretched is that string by the gravitational force and then returns the Acceleration on that axis.
To get more information about the Accelermoter sensor inside your smartphone and how it works. Please check out this amazing short video:
Now that we know how an Arduino Accelerometer sensor works, let’s use the Arduino Accelerometer shield by downloading 1Sheeld library, to access its functions.
1Sheeld Arduino Accelerometer shield functions
The first 3 functions: getX, getY, and getZ
These are the 3 main functions of the Arduino Accelerometer shield, they get the acceleration of your smartphone on each axis so you are able to get the smartphone position.
Hence, you realize it has no parameters and 1 return value which is the Acceleration on the X, Y, and Z axis and the returned values are floats.
The syntax for these functions are:
So, it will be a perfect match for a gesture control project like the one Adham made using 1Sheeld to unlock his door lock with the Arduino Accelerometer Shield.
Adham has made here a certain pattern with the Arduino Accelerometer Shield readings so he will move the smartphone on the x-axis then he will move it again but in the y-axis and as a result of that the lock will be freed.
Linear Acceleration option
As a result, of checking the linear acceleration inside the Arduino Accelerometer Shield, the returned values will exclude the value of gravitational force. So it will give you the exact linear acceleration on each axis (X-Y-Z).
Finally, the setOnValueChange function
This is a default function in all 1Sheeld Arduino shields, it indicates a change in any of the values of a certain sensor shield, which in this case: The Arduino Accelerometer shield.
This function triggers a function written by the user to run once there is a change in the X, Y or Z-axis value.The syntax for this function is:
/* Print x-y-z axis values on the Terminal Shield. */
Finally, I hope I have covered all the Arduino Accelerometer Shield functions very clearly. And if you have any query, please let me know down in the comments.
And of course, don’t forget to check out lots of Arduino Projects made using 1Sheeld. Especially, that many of them have used the Arduino Accelerometer shield.
In addition to playing games, joysticks have several usages in hardware projects. This includes controlling actuators and output devices, such as motors and speakers, or controlling pixels on a screen. In this article, I will introduce you to the best 5 Arduino joystick shields. Arduino joystick shields usually have at least one analog joystick with …
You know when you download Google Earth and, out of the thousands of streets you can go to from the comfort of your chair, you choose to check out your home. Now you could do that automatically, just connect your GPS shield to your Arduino and, point it to the sky. Your home coordinates will …
Today I’ll be explaining the functions of the Arduino GPS shield in 1Sheeld and how to use it to get longitude and latitude locations. The Arduino GPS shield in 1Sheeld allows you to use your smartphone as a GPS receiver to be able to track your Arduino project wherever it is, using the GPS sensor …
It’s now the age were the word “Hack” is a relevant word we see and hear everywhere, and i don’t mean the software cyber hacks,I am talking about DIY hacks 😀 . We made this Home Automation Hacks series to help you add fun features to your home stuff by doing it yourself 😉 . …
Welcome to our home automation hacks series #2, today I am going to show you how to hack your home outlets with Arduino and a phone gesture 😉 .This time I used Accelerometer sensor shield from 1Sheeld application. And with a simple gesture it will open\close the outlet to trigger the fan on or off …
Whenever it’s time to get off the office, I always check the traffic status to choose the best time to go home. But I couldn’t find a way to do that autonomously. So then …. I was up to make a system that shows me the current traffic status with the help of a simple tool that is used …