Arduino Accelerometer Shield Functions Explainer

Today I’ll be explaining the functions of the Arduino Accelerometer shield in 1Sheeld and how to use it to control things with gesture control.

The Arduino Accelerometer shield in 1Sheeld allows you to use your smartphone as an Accelerometer sensor so you can get the changes in gravity in 3 dimensions which are X, Y, and Z-axis.

If it’s the first time to hear of 1Sheeld board or didn’t use it before then it will be nice of you to check 1Sheeld’s getting started tutorial and then get back here.

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

  • .getX();
  • .getY();
  • .getZ();
  • .setOnValueChange();

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:

  • AccelerometerSensor.getX();
  • AccelerometerSensor.getY();
  • AccelerometerSensor.getZ();

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:


and here is an example of this function:

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.

Related Blogs

Arduino Plant Watering System

Arduino Plant Watering System (Arduino Home Hacks #3)

Welcome to our home automation hacks series #3, for so many times I had problems with watering my plants while traveling abroad and I have always needed a way to control it remotely, then I decided to do it with one of the fanciest ways you may ever hear off, cause I’m gonna water my …

Arduino Accelerometer Projects

Top 7 Arduino Accelerometer Projects made using 1Sheeld

Adding motion as an input for your project is going to be so much fun! You can do this by using an Accelerometer Module that measures acceleration in three linear axes (X, Y, Z) and then you can translate it into actions. Today, our topic is all about Arduino Accelerometer projects. In fact, Arduino Accelerometer …

Display traffic status on an IKEA clock with Arduino and 1Sheeld

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 …

Arduino’s SoftwareSerial vs AltSoftSerial: Which library to use with 1Sheeld+ ?

The newer version of 1Sheeld (1Sheeld+) built to support both iOS and Android devices,but not just that …! There’s another secret feature supported to solve the problem of using extra shield/board over 1Sheeld+, and this shield/board have the same way of communication used by 1Sheeld+ (The hardware UART serial pins pin0&pin1) with your Arduino. Exactly …

Log noise level on cloud using Arduino & 1Sheeld

Nowadays people started integrating stuff with the internet for their daily uses, and fortunately, it’s not hard to do so..! as there are a lot of hardware/software tools that ease the development of such applications. One of these tools is the 1Sheeld’s Internet shield, which allows your arduino board to connect to a mobile application …

Control home lights with your voice (Arduino Home Hacks #1)

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 😉 . …