• Support
  • Cart
Phinalabs Phinalabs
  • Shop
    • STEM Education
    • Makers
    • Components
    • Tools
  • Lab
    • Fabrication
    • Projects
    • Open Source
  • Education
    • Create.Innovate.Invent
    • Resources & Kits
  • Learn
    • STEM
      • Basics
      • Coding
      • Kits
      • DIY
    • Explore
      • Basic Electronics
      • Microcontrollers
      • Displays
      • Modules
      • Actuators
      • Sensors
    • Industrial & IoT
    • Embedded Systems
      • Embedded C
      • Embedded OS
      • Micropython
      • PCB Making
  • Blog
  • Register
  • Login|
LoginRegister
­
Learn/Explore/MMA7361LC 3-Axis Accelerometer

Close

MMA7361LC 3-Axis Accelerometer

By Muchiri John

Share this project

Introduction

This Module is a 3-axis Xyz accelerometer using Freescale MMA7361L micromachined ±1.5g  or ±6g sensitivity. It’s great for a motion sensing or stability control project e.g in robotics, anti-theft devices or even game pads. It’s simple to interface to any microcontroller as the XYZ axes outputs analog values.

Pinout
MMA7361 3 axis accelerometer Sensor

Description

– 0g-Detect pin is used to detect free fall, that is, if all the three axes simultaneiusly detect 0g.
– The X, Y and Z axis ouputs analog volatge centered at VDD/2, positive accelerations will results in a value higher than VDD/2 and negative accelerations will result in a value lower than VDD/2.
– Sleep pin is used to put the sensor into low-power mode which is crucial especially in battery powered applications. This pin is internally pulled low and you must pull it high when using the sensor either by connecting it directly to VDD or to microcontroller pin if you want to control it.
– The g-Select pin is used to set the sensitivity of the sensor. When pulled down its ±1.5g (800 mV/g) or pulled up its ±6g (206 mV/g).
– VDD is usually powered from 2.7V to 3.6V power supply therefore the board is not 5V tolerant.

Part List

We’ll connect the module to an Arduino board. Part list needed.
– MMA7316lL accelerometer module
– Arduino Pro Mini
– FTDI FT232RL USB-Serial (for uploading code to pro mini)
– Mini breadboard
– Jumper packs (Male-Male)

Wiring

We are connecting the MMA7316 module to an Arduino pro mini running at 8Mhz, 3.3V. Since our power supply is 3.3V we dont need a level converter I.C for this tutorial. To upload code to the Arduino pro mini, we’ll use FTDI FT232RL USB-Serial module.

Sensor-Arduino pin connections

Module Arduino Pro Mini
0g-Detect NC
X A0
Y A1
Z A2
Ground Ground
Vcc Vcc(3v)
Ground Ground
Sleep Vcc (3V)
g-Select VCC (6g) or Ground (1.5g)
Self Test NC

Breadboard Connections

MMA7361 Acceleration Module

MMA7361 Acceleration Module

Code

Here’s the Arduino code for our tutorial

C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
*
* Connections
*  -------------------
*  Sensor  |   Pro Mini
*  -------------------
*    X     |     A0          
*    Y     |     A1
*    Z     |     A2
*    VCC   |     3.3V
*    GND   |     GND
*    SLEEP |     3.3V
*  -------------------
*  
*/
//macro definnitions
#define a_x A0
#define a_y A1
#define a_z A2
 
//calibrate your readings,(VDD/2), to get ± values
const uint16_t a_x_cal = 518;
const uint16_t a_y_cal = 530;
const uint16_t a_z_cal = 556;
 
//variables to hold axes values
uint16_t acc_X = 0;
uint16_t acc_Y = 0;
uint16_t acc_Z = 0;
 
//setup method
void setup() {
//set serial baudrate at 9600
Serial.begin(9600);
 
}
 
//loop method
void loop() {
  //print accelerometer values
  PrintAccValues();
  //delay 200 ms
  delay(200);
}
 
//print axes method
void PrintAccValues()
{
  //print X axis values
  acc_X = analogRead(a_x) - a_x_cal;
  Serial.print("X : "); Serial.print(acc_X); Serial.print("    ");
  //print Y axis values
  acc_Y = analogRead(a_y) - a_y_cal;
  Serial.print("Y : "); Serial.print(acc_Y); Serial.print("    ");
  //print Y axis values
  acc_Z = analogRead(a_z) - a_z_cal;
  Serial.print("Z : "); Serial.print(acc_Z); Serial.println();
}

How the Code Works

In the macro definitions we define analog (A0, A1 and A2) pins used on the Pro Mini for the sensor’s XYZ axes.

mma7361 accelerometer
C
1
2
3
#define a_x A0
#define a_y A1
#define a_z A2

The sensor readings are either above (positive g) or below (negative g) VDD/2, so we set constants for each axis for VDD/2 values. To get the constants, make sure the sensor is placed on a flat surface.

mma7361 accelerometer
C
1
2
3
const uint16_t a_x_cal = 518;
const uint16_t a_y_cal = 530;
const uint16_t a_z_cal = 556;

Finally we have the ‘PrintAccValues()’ funtions being called continously in the loop method. Its main function is to get and print XYZ axes values to the serial port. e.g for X axis, we have;

mma7361 accelerometer
C
1
2
acc_X = analogRead(a_x) - a_x_cal;
Serial.print("X : "); Serial.print(acc_X); Serial.print("    ");

Running the Code

First select port, then select ‘Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328’ in the boards dropdown list and finally click ‘Run on Arduino’ to upload code to your Arduino pro mini.

Serial Monitor

We’ll use the serial monitor to view XYZ axes values. Set baudrate to 9600 and click ‘connect’ (Use the FTDI FT232R USB-Serial module to connect the board to the computer) to enable serial communication.

Resources

– MMA7316L  Datasheet
– Arduino Code
– Wiring Diagram

Share this post

Like this project

Tags

accelerometer Arduino breadboard buzzer color sensor digital input jumper jumpers jumper wires kit learn led LED blinking PIR programming prototyping resistors scratch-n-sketch Scratch_n_Sketch sensors tcs3200 touch

Feedback

You must be logged in to leave feedback.


Related Projects

  • thumbnail_unda_project_1

    UNDA Project 1: Flashing Light


    By Mercy Ngoiri

    [fullwidth background_color="" background_image="" background_parallax="none" enable_mobile="no" parallax_speed="0.3" background_repeat="no-repeat"...

  • tcs3200_cl_02

    Color Sensor TCS3200


    By Muchiri John

    This module is based on TCS3200 programmable color light-to-frequency converters that combine configurable silicon photodiodes and a current-to-fre...

  • pir_motion_02

    PIR Motion Sensor


    By Muchiri John

    A PIR motion sensor, is a small, low power and inexpensive sensor that is used to sense objects emitting low level radiation e.g humans, cats, dogs...

  • touch_sensor

    Touch Sensor


    By Dennis

    If you are interested in adding the ‘magic’ of touch to control your electronics project, a capacitive touch sensor module might be the way to go. ...

  • ard_piezo_image

    Piezo Buzzer


    By Dennis

    This tutorial shows how to hook up a piezo buzzer and an Arduino Uno board to make a simple sound alarm whose volume can be adjusted . The buzzer i...

  • Arduino_Logo

    Arduino : Getting Started


    By Mercy Ngoiri

    In this lesson we will learn how to set up the computer to get started with Arduino, that is, downloading and installing the software and then open...

  • Arduino_Logo

    Arduino : Introduction


    By Muchiri John

    Arduino is an open-source prototyping platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sens...

Sections

  • Introduction
  • Part List
  • Wiring
  • Code
  • Resources
Paginate View
Feedback
Get Updates

Customer Service

  • Contact Page
  • Support
  • Distributors
  • FAQ Page

Terms of Use

  • Shipping & Returns
  • Terms of Service

About Us

:: Phinalabs designs and manufactures electronics and provides a platform - tools, resources, and content for our partners and community of makers, DIYers, engineers, students, innovators, and inventors to build, learn, connect, inspire, and turn ideas into reality.

"Fairy tales are more than true: not because they tell us that dragons exist, but because they tell us that dragons can be beaten."
Neil Gaiman