The Alpha Geek – Geeking Out

Project #6: MicroView – Accelerometer ADXL335 – Mk06

Accelerometer

An accelerometer is a device that measures proper acceleration. Proper acceleration, being the acceleration (or rate of change of velocity) of a body in its own instantaneous rest frame, is not the same as coordinate acceleration, being the acceleration in a fixed coordinate system. For example, an accelerometer at rest on the surface of the Earth will measure an acceleration due to Earth’s gravity, straight upwards (by definition) of g = 9.81 m/s2. By contrast, accelerometers in free fall (falling toward the center of the Earth at a rate of about 9.81 m/s2) will measure zero.

Triple Axis Accelerometer Breakout – ADXL335

Breakout board for the 3 axis ADXL335 from Analog Devices. This is the latest in a long, proven line of analog sensors – the holy grail of accelerometers. The ADXL335 is a triple axis MEMS accelerometer with extremely low noise and power consumption – only 320uA! The sensor has a full sensing range of +/-3g. There is no on-board regulation, provided power should be between 1.8 and 3.6VDC. Board comes fully assembled and tested with external components installed. The included 0.1uF capacitors set the bandwidth of each axis to 50Hz.

DonLuc1805Mk05

1 x MicroView
1 x MicroView – USB Programmer
1 x Accelerometer ADXL335
5 x Jumper Wires 3″ M/M
1 x Half-Size Breadboard

MicroView

Z-Axis – PIN 07 – Analog A0
Y-Axis – PIN 06 – Analog A1
X-Axis – PIN 05 – Analog A2
VIN – PIN 16 – 3.3V
GND – PIN 08 – GND

DonLuc1805Mk05a.ino

// ***** Don Luc *****
// Software Version Information
// 6.01
// DonLuc1804Mk06 6.01
// MicroView
// Accelerometer ADXL335

// include the library code:
#include <MicroView.h>
#include <ADXL335.h>

// Accelerometer ADXL335
const int pin_x = A0;     // X-Axis
const int pin_y = A1;     // Y-Axis
const int pin_z = A2;     // Z-Axis
const int vin = 16;       // 3.3V
const int gnd = 8;        // GND

ADXL335 accel(pin_x, pin_y, pin_z, vin);

void loop() {

  // Accelerometer ADXL335
  isADXL335();

  delay(500);
  
  uView.clear(PAGE);  // Erase the memory buffer, the OLED will be cleared
  
}

getADXL335.ino

// Accelerometer ADXL335
void isADXL335(){

  // This is required to update the values
  accel.update();

  float rho;
  float phi;
  float theta;  
  
  rho = accel.getRho();
  phi = accel.getPhi();
  theta = accel.getTheta();

  uView.setFontType(0);  // Set font type 0: Numbers and letters. 10 characters per line (6 lines)
  
  uView.setCursor(0,10); // X-Axis
  uView.print( "X: " );
  uView.print( rho );

  uView.setCursor(0,20); // Y-Axis
  uView.print( "Y: " );
  uView.print( phi );

  uView.setCursor(0,30); // Z-Axis
  uView.print( "Z: " );
  uView.print( theta );
     
  uView.display();       // Display
  
}

setup.ino

void setup() {

  uView.begin();           // Begin of MicroView
  uView.clear(ALL);        // Erase hardware memory inside the OLED controller
  uView.display();         // Display the content in the buffer memory, by default it is the MicroView logo
  
  delay(1000);
  
  uView.clear(PAGE);       // Erase the memory buffer, the OLED will be cleared.
   
  uView.setFontType(1);    // Set font type 1: Numbers and letters. 7 characters per line (3 lines)
  uView.setCursor(0,20);
  uView.print("Don Luc");  // Don Luc
  uView.display();         // Display
  
  delay(5000);

  uView.clear(PAGE);       // Erase the memory buffer, the OLED will be cleared.

  uView.setFontType(1);    // Set font type 1: Numbers and letters. 7 characters per line (3 lines)
  uView.setCursor(0,20);
  uView.print("ADXL335");  // ADXL335
  uView.display();         // Display
  
  delay(5000);
  
  uView.clear(PAGE);       // Erase the memory buffer, the OLED will be cleared
 
  // Accelerometer ADXL335
  pinMode(gnd, OUTPUT);    // GND
  pinMode(vin, OUTPUT);    // 3.3V
  digitalWrite(gnd, LOW);
  digitalWrite(vin, HIGH);
  
}

Don Luc

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories
Archives