Grove - Introduction in 3-Axis Digital Accelerometer

Grove - Introduction in 3-Axis Digital Accelerometer © GPL3+

How to use a 3-axis digital accelerometer.

  • 1,837 views
  • 2 comments
  • 3 respects

Components and supplies

Apps and online services

About this project

Introduction

I would like to share my first steps with the Grove 'plug & play' components.

This is primarily about the 3-Axis Digital Accelerometer - also called 'Gyro'. Once the Grove Base Shield has been mounted on the Arduino Uno R3, the Grove Universal Cable of the Gyro can be connected to one of the I2C ports.

I use the Arduino WebIDE and have created 2 more tabs for Libary named MMA7660.cpp and MMA7660.h. Copy the code using copy & paste, and copy the original sample code from Seeedstudio attached.

The values determined in the serial monitor of the WebIDE are listed accordingly.

The gyro is then considered as a component as soon as movements are used both horizontally and vertically in the project.

This short introduction reflects the available original example of Seeedstudio.

Further examples with a introduction in components from Grove Starter Kit can be found here:

More projects under my account.

Code

Accelerometer-ExampleC/C++
Original Example Code by seeedstudio.com
/*****************************************************************************/
//	Function:    Get the accelemeter of the x/y/z axis. 
//  Hardware:    Grove - 3-Axis Digital Accelerometer(±1.5g)
//	Arduino IDE: Arduino-1.0
//	Author:	 Frankie.Chu		
//	Date: 	 Jan 10,2013
//	Version: v0.9b
//	by www.seeedstudio.com
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//
/*******************************************************************************/

#include <Wire.h>
#include "MMA7660.h"
MMA7660 accelemeter;
void setup()
{
	accelemeter.init();  
	Serial.begin(9600);
}
void loop()
{
	int8_t x;
	int8_t y;
	int8_t z;
	float ax,ay,az;
	accelemeter.getXYZ(&x,&y,&z);
	
	Serial.print("x = ");
    Serial.println(x); 
    Serial.print("y = ");
    Serial.println(y);   
    Serial.print("z = ");
    Serial.println(z);
	
	accelemeter.getAcceleration(&ax,&ay,&az);
    Serial.println("accleration of X/Y/Z: ");
	Serial.print(ax);
	Serial.println(" g");
	Serial.print(ay);
	Serial.println(" g");
	Serial.print(az);
	Serial.println(" g");
	Serial.println("*************");
	delay(500);
}

Comments

Similar projects you might like

Free Fall Detection Using 3-Axis Accelerometer

by RVLAD

  • 2,684 views
  • 0 comments
  • 8 respects

Visual Accelerometer

Project tutorial by Reid Paulhus

  • 6,049 views
  • 2 comments
  • 16 respects

Level Platform Using Accelerometer

Project tutorial by Mark Tashiro

  • 23,106 views
  • 19 comments
  • 36 respects

Stepper - A First Introduction to Nema 17

by Ingo Lohs

  • 13,095 views
  • 7 comments
  • 64 respects
Add projectSign up / Login