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 Security Camera

Arduino Security Camera System (Arduino Home Hacks #4)

Arduino Security Camera Have you ever wanted to check your home in real time? Afraid that maybe someone has stormed in, don’t remember if you shut the door or not or maybe wanna check if your Hyper-energetic dog has broken any of your dishes AGAIN!! 🙂 Then this is the perfect place for you cause today …

Arduino IoT

Arduino IoT Shield Functions Explainer

Arduino makers …. you can connect your Arduino to MQTT brokers(servers) and launch your IoT with Arduino IoT Shield! It’s the 1Sheeld IoT shield that will do the job for you. It’s one of the most important but recent Arduino shields in 1Sheeld. Simply, it turns your Arduino into MQTT client where you can publish and …

Arduino Temperature Humidity System

IoT Arduino Temperature and Humidity System

Monitor my home environmental parameters remotely is one of the most desirable things I have ever wanted to make. It’s not about purchasing such a system that can get the job done for me. But, passion to create it myself. So, today, I am going to connect the popular DHT sensor to an online MQTT …

Arduino Door Lock

IoT Arduino Door Lock using 1Sheeld and Smartphone

  “Oh God! … It seems like I have forgotten the door lock open, again” … the normal saying whenever I am in hurry to go out! Have you encountered this problem before? It always confuses me since I may even think that I have left the door lock opened, and once I go back, …

IoT Fan Control

Arduino IoT Fan Control using 1Sheeld and Smartphone

Here I am with another IoT-based home automation project; Arduino IoT Fan Control. Every day, I get back from work tired and feeling hot. No air conditioner here and the fan takes much time to start cooling the room, sadly! So, I was thinking why not controlling the fan from outside my home with my …

Arduino Light Control

IoT Arduino Light Control using 1Sheeld and Smartphone

Have you ever forgotten to turn your home lights off when you got outside? Sadly, it happens to me all the time. And this causes confusion once I get my bills! Furthermore, here is one secret about me; I am a lazy man. I always want to control my room lamp from my sweet bed. …