Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: LazuriteGraph_Hello KX022_Hello GR-PEACH_IoT_Platform_HTTP_sample
KX022 Class Reference
KX022 accelerometer example. More...
#include <KX022.h>
Public Member Functions | |
| KX022 (PinName sda, PinName scl, int addr=KX022_DEFAULT_SLAVE_ADDRESS) | |
| KX022 constructor. | |
| KX022 (I2C &i2c_obj, int addr=KX022_DEFAULT_SLAVE_ADDRESS) | |
| Create a KX022 instance which is connected to specified I2C pins with specified address. | |
| ~KX022 () | |
| KX022 destructor. | |
| void | initialize (void) |
| Initializa KX022 sensor. | |
| float | getAccX () |
| Get X axis acceleration. | |
| float | getAccY () |
| Get Y axis acceleration. | |
| float | getAccZ () |
| Get Z axis acceleration. | |
| void | getAccAllAxis (float *res) |
| Get XYZ axis acceleration. | |
Detailed Description
KX022 accelerometer example.
#include "mbed.h" #include "KX022.h" int main(void) { KX022 acc(I2C_SDA, I2C_SCL); PwmOut rled(LED_RED); PwmOut gled(LED_GREEN); PwmOut bled(LED_BLUE); while (true) { rled = 1.0 - abs(acc.getAccX()); gled = 1.0 - abs(acc.getAccY()); bled = 1.0 - abs(acc.getAccZ()); wait(0.1); } }
Definition at line 81 of file KX022.h.
Constructor & Destructor Documentation
| KX022 | ( | PinName | sda, |
| PinName | scl, | ||
| int | addr = KX022_DEFAULT_SLAVE_ADDRESS |
||
| ) |
| KX022 | ( | I2C & | i2c_obj, |
| int | addr = KX022_DEFAULT_SLAVE_ADDRESS |
||
| ) |
Member Function Documentation
| void getAccAllAxis | ( | float * | res ) |
| float getAccX | ( | ) |
| float getAccY | ( | ) |
| float getAccZ | ( | ) |
Generated on Fri Jul 15 2022 08:19:45 by
1.7.2
Rohm/Kionix KX022-1020 | Accelerometer