Basic measurement with accelerometer GY-61 with ADXL335 chip

With this module, you can measure:

  1. acceleration (= speed of movements) in three directions x, y, z;
  2. a rotation or an angles (in three directions);
  3. orientation

In this program, there is only a simple basic measurement of an angle in one direction, just to show how this works.

I also made use of the possibility to use an analog-ports as an output to put VCC (5V) and GND (0V) on the GY-61-module (see picture A0 = VCC and A4 = GND).

GY-61-UNO-1 GY-61-UNO-2

This is simple code to show an angle on the serial monitor:

// This is a simple working-example to quick measuring:
// 1. the x, y and z-values read from a GY-61-acceleration-module
// 2. an angle in eg. the x-direction

// You can put the module in 4 directions to determine the min-max-values:
// –>   0deg   x = 349  y = 341  z = 425
// /\    90deg  x = 281  y = 345  z = 357
// <–  180deg  x = 350  y = 345  z = 288
//  V   270deg  x = 419  y = 341  z = 355
// This can be used to measure degrees

// you can use all the analog inputs to control the GY-61
// picture:
const int VCCPin = A0;
const int xPin   = A1;
const int yPin   = A2;
const int zPin   = A3;
const int GNDPin = A4;

// variables
int x = 0;
int y = 0;
int z = 0;

void setup() {
// pin A0 (pin14) is VCC and pin A4 (pin18) in GND to activate the GY-61-module
pinMode(A0, OUTPUT);
pinMode(A4, OUTPUT);
digitalWrite(14, HIGH);
digitalWrite(18, LOW);

// activating debugging for arduino UNO
} // end setup

void loop() {
x = analogRead(xPin);
y = analogRead(yPin);
z = analogRead(zPin);
// show x, y and z-values
Serial.print(“x = “);
Serial.print(”  y = “);
Serial.print(”  z = “);
// show angle
Serial.print(”  angle = “);
} // end loop

To find further information, on rotation and acceleration, check other sites:

This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Basic measurement with accelerometer GY-61 with ADXL335 chip

  1. Pingback: Using ADC with the ESP8266 | Austinlightguy's Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s