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.
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 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 …
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 …
“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, …
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 …
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. …