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 Joystick

Top 5 Arduino Joystick Shields

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 …

Arduino GPS logger

Top 5 Arduino GPS logger shields

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 …

Arduino GPS

Arduino GPS Shield Functions Explainer

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 …

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

Control a fan with smartphone gesture (Arduino Home Hacks #2)

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 …

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 …