PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Devices
Sensor
Accelerometer 3-Axis MMA7455
Test MMA7455.c
1
/*
2
Test MMA7455.c
3
4
Test the Parallax MMA7455L 3 Axis Accelerometer module.
5
6
http://learn.parallax.com/propeller-c-simple-devices/mma7455-three-axis-accelerometer
7
*/
8
9
#include "
simpletools.h
"
// Include simpletools header
10
#include "
mma7455.h
"
// Include mma7455 header
11
12
short
x
, y, z;
// Axis variables
13
14
int
main
()
// Main function
15
{
16
17
MMA7455_init
(7, 8, 6);
// I/O to: DATA, CLK, /CS
18
19
while
(1)
// Main loop
20
{
21
22
MMA7455_getxyz10
(&
x
, &y, &z);
// Get acceleration measurements
23
print
(
"%c x=%d, y=%d, z=%d %c"
,
// Display measurements
24
HOME
,
x
, y, z,
CLREOL
);
25
26
pause
(200);
// Wait 200 ms before repeat
27
}
28
}
29
MMA7455_getxyz10
void MMA7455_getxyz10(signed short *x, signed short *y, signed short *z)
Get 10 bit x, y, and z axis measurements. The range is +/- 8 g with values of +/- 64 corresponding to...
Definition:
getxyz10.c:23
HOME
#define HOME
HOME character (1) sends SimpleIDE Terminal's cursor to top-left "home" position.
Definition:
simpletools.h:233
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
main
int main(void)
Definition:
GraphicsTest.c:20
MMA7455_init
void MMA7455_init(int pinData, int pinClock, int pinEnable)
Initialize the sensor.
Definition:
init.c:23
x
int x
Definition:
07 Box and Lines.c:13
CLREOL
#define CLREOL
CLREOL character (11) erases all SimpleIDE Terminal characters to the right of the cursor.
Definition:
simpletools.h:323
mma7455.h
Simplifies reading Parallax MMA7455 3-Axis Accelerometer Module.
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17