ADXL326 Accelerometer Questions

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

ADXL326 Accelerometer Questions

Postby Blake81 » Mon Jan 07, 2013 5:50 am

I'm trying to get this accelerometer working. I'm going to be using it with the GPS logger in a high-altitude balloon. I have one problem and a question. When I run this code, I get values of 14, 15, and 16 for X Y and Z, respectively. Does it make sense to get those values? Also, the problem is that, when I run this code, the values don't change. Can you see why this is happening? Thanks.

Code: Select all
const int xInput = A0;
    const int yInput = A1;
    const int zInput = A2;
     
    void setup()
    {
    analogReference(EXTERNAL);
    Serial.begin(9600);
    }
     
    void loop()
    {
    int xRaw = xInput;
    int yRaw = yInput;
    int zRaw = zInput;
   
    Serial.print("X: ");
    Serial.print(xRaw);
    Serial.print(", Y: ");
    Serial.print(yRaw);
    Serial.print(", Z: ");
    Serial.print(zRaw);
String AccValues = ",Accel=";
AccValues = AccValues + xRaw + yRaw + zRaw;
Serial.print(AccValues);
    }
User avatar
Blake81
 
Posts: 13
Joined: Thu Jul 05, 2012 2:11 pm
Location: Carrollton, GA

Re: ADXL326 Accelerometer Questions

Postby adafruit_support_bill » Mon Jan 07, 2013 6:06 am

Your loop isn't reading from the sensor. You are just assigning x, y & z raw to some variables that never change.
Code: Select all
    int xRaw = xInput;
    int yRaw = yInput;
    int zRaw = zInput;


You need to read from the pins that your ADX326 is connected to. To minimize noise, use the "readAxis()" function from the calibration sketch in the tutorial for your readings. http://learn.adafruit.com/adafruit-anal ... rogramming

Code: Select all
int xRaw = ReadAxis(xInput);
int yRaw = ReadAxis(yInput);
int zRaw = ReadAxis(zInput);
User avatar
adafruit_support_bill
 
Posts: 15898
Joined: Sat Feb 07, 2009 9:11 am


Return to Other Arduino products from Adafruit

Who is online

Users browsing this forum: mibignistinly and 3 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]