We covered the basics of accelerometer previously in Using Arduino with Parts and Sensors – Accelerometer Part 1 and Using Arduino with Parts and Sensors – Accelerometer Part 2. Today we’ll be testing KX022-1020 accelerometer using TFT liquid crystal panel. We’ll discuss how to control the TFT LCD in more detail in the next article. In addition, we’ll further explore Arduino Create. For more information about Arduino Create, please refer back to this article.
Estimated time to complete: 90 minutes
※ Rohm sensor evaluation kit can be purchased from the following site!
Let’s briefly review what accelerometer is. An accelerometer is a sensor that can detect the state of motion, such as “tilt,” “shock,” “vibration” and so forth. Accelerometers are classified into one axis, two axes, and three axes. For example, one axis detects one direction (vertical only); two axes detects two directions (vertical and horizontal); and three axes three directions (vertical, horizontal and height).
Since the accelerometer integrated in the Sensor Evaluation Kit has three axes, it’s able to detect XYZ coordinates.
KX022-1020 is a 3-axis accelerometer. There is a display of XYZ on the sensor like the geomagnetic sensor.
We’ll continue using Arduino Create Web Editor as we did in our last tutorial. To add the library, you can upload the zip file by selecting it from “Libraries” on the left menu and clicking on “ADD ZIP LIBRARY.”
After adding the library, attach the accelerometer to the Sensor Shield (I2C I/F) and try running the sample program. The accelerometer should be set to 1.8V or 3.0V.
To open the sample program, click on “Libraries” and then “KX022” under “CUSTOM”.
After compiling and uploading it to Arduino, you’ll able to see values displayed on the serial monitor.
Now the sample program is working fine, let’s try to display the values on a 1.8 inch TFT LCD monitor. Although this TFT liquid crystal monitor has a resolution slightly smaller than 126 x 160 px, it’ll be quite useful when displaying numbers or letters with Arduino etc.
In the past, we used 7-segment LED to display numerical values only. But this time, I tried to display the graph along with the values obtained from the accelerometer.
When using the TFT monitor, the connection method and the library used in the program may be different depending on the specification of each TFT monitor. The TFT monitor used in this tutorial is a monitor SainSmart ST7735R. In addition to Arduino, the monitor is also compatible with Raspberry.
In order to use the monitor to run the program in Arduino, we’ll have to modify the downloaded library a little bit. We’ll go over how to control the TFT LCD in more detail in the next article. Once everything is set, you will be able to output numerical values in the monitor as shown in the video below:
In the next part, we’ll create a simple device using the same accelerometer and TFT monitor. We’ll show how to create graphs and display the values obtained from the accelerometer on the TFT monitor.