Adding an Adxl to my board

I have a couple of 'things' hooked up to a number of pins on my arduino uno. I have hooked up my adxl 335 accelerometer to the analog pins on the arduino before, and it worked. I was wondering if there was a different place to hook up my adxl connetions without using the pins i originally had to use. i have been trying different connections, but haven't hit the right combo yet.

Pins in use on arduino:
3.3V
5V
GND, both of them
A0
A1

My original adxl connections are
Arduino- adxl
A0-self-test
A1-z axis
A2-y axis
A3-x axis
A4-ground
A5-vcc

The best thing to do is use a proto board or something to get more connections to your 3.3v and Gnd. You will need more connections to Gnd and 5V if you want to add Leds. What I am speaking of is a parallel connection. With GND for example, you come from the GND pin and with board you can have a copper strip that would allow more connections to be connected to GND.

If you do the above you will only need A1-z axis, A2-y axis, A3-x axis, and self test is optional.

Mark

Yes, a breadboard has parallel connections that can be used for multiple pwr and GND. You are most likely on the right track.

Mark

You will need analog pins to sense the accelerometer. Digital pins only sense on and off. I suggest you get a small breadboard. Pass power and ground to the breadboard with jumper wires. Breadboards have busses, columns of holes that are connected. You jump power to one of those holes and the rest on the same column are all connected to power.

My accelerometer has been in a breadboard. The power is in the Vin pin, and the gnd is in the digital side. Is that OK? I have my x,y,and z in analog pins now. However, now my x axis is showing a reading of 0, regardless. I have two codes- one just for the readouts, and the other with an alarm. I was trying to get the plain code to work, so i could adapt it for my project, but it wasn't working. My alarm code, however, I have gotten to start working properly, so i will just use that for the time being.
The alarm code takes the difference (movement) of the adxls axis, and then prints low (normal) or high (moving), and lights the LED when it is on high.

Continuing the matter, i have a sensor system hooked up and running. What it does is if the two sensor values are above the alarmValue, it lights the LED. I am trying to add the adxl, so that when the two sensor values are above the alarmValue, and the adxl is on HIGH, the LED will light up. I'm not sure how to add the LED system in, because it is not based on an alarmValue.

Two sensor code

if (corda > alarmValue  && toad > alarmValue)
  {
    digitalWrite (ledPin, HIGH); // turn the LED on
  } 

  else 
  { 
    digitalWrite (ledPin, LOW); 
  }

How i tried to modify it...

 //    if ((ybase-ypin) >= 100) //makes the high, low signals
  if ((abs(yy-ybase) >= diff) && (abs(zz-zbase)>= diff))
 { 
  digitalWrite(xbackward, HIGH);
  Serial.print("high= ybase \t");
  Serial.print(yy-ybase);
  //Serial.print(  analogRead(ybase)-ypin);
   Serial.print("cc \t");
  //Serial.print(abs(zbase-zpin));
 }
 else
 {
   digitalWrite(xbackward, LOW);
  Serial.print("low \t");  
 };
 
if (corda > alarmValue  && toad > alarmValue && (xbackward, HIGH))  
  {
    digitalWrite (ledPin, HIGH); // turn the LED on
  } 

  else 
  { 
    digitalWrite (ledPin, LOW);

You can use any of the GND pins on the Arduino they are all connected together. For power to the adxl 335
you should connect 3.3v pin on the Arduino.

Here is Sparkfun's page on that unit. http://www.sparkfun.com/products/9269

Here is a builder example found at sparkfun's page http://bildr.org/2011/04/sensing-orientation-with-the-adxl335-arduino/

I would like to help you with your code too but, you need to post all of it so that I can figure out how defined "xbackward" and things like that.

Mark

Thanks Mark, I wasn't sure if i should post all my code. I have the adxl powered and working correctly.
Here is the full adxl code, and it is giving me the proper readings.

const int xpin = A4;                 
const int ypin = A3;                 
const int zpin = A2;                 
int ledPin = 13; 	 
float alarmValue;  
int xforward = 6;
int xbackward = 7;
int ledState = LOW;
int xbase = 467;
int ybase = 490;
int zbase = 540;
int diff = 30; 

int xx;
int yy;
int zz;

void setup()
{
  
  Serial.begin(9600);
  Serial.println("Ready");
   alarmValue = 25; 
}

void loop()
{
  
  
  Serial.print(analogRead(xpin));
    Serial.print("x \t");
  yy = analogRead(ypin);
  Serial.print(analogRead(ypin));
    Serial.print("y \t");
  Serial.print(analogRead(zpin));
  zz = analogRead(zpin);
  Serial.println("z");
    delay(1000);
      if ((abs(yy-ybase) >= diff) && (abs(zz-zbase)>= diff))
 { 
  digitalWrite(xbackward, HIGH);
  Serial.print("high= ybase \t");
  Serial.print(yy-ybase);
     Serial.print("cc \t");
   digitalWrite (ledPin, HIGH); 
 }
 else
 {
   digitalWrite(xbackward, LOW);
  Serial.print("low \t");  
  digitalWrite (ledPin, LOW); 
 };
}

Most of your commented codes are wrong. Please remove them. There's no point in keeping them. If you power the accelerometer with 3.3V, did you use 3.3V as analog reference voltage? No, according to your setup(). So your base value is not near 500 but near 338. That is the first thing I noticed. If you set the accelerometer flat, what do you get for x and y? 338 or near 500?

What do you to accomplish? You said nothing about it. From what I know, you can only sustain acceleration with circular motion. So your acceleration goes above alarm only for a short moment before you need to decelerate.

I am not using the 3.3V, i am using Vin. I simply want a sensor to alert me if there is any movement. if there is, just light a LED.

uink:
I am not using the 3.3V, i am using Vin. I simply want a sensor to alert me if there is any movement. if there is, just light a LED.

Vin is supposed to be connected to the positive lead on a battery or an ac adapter (wall wart), thus the 'in'. It's not supposed to supply power to your accelerometer. Please post your project pic.

Vin is supposed to be connected to the positive lead on a battery or an ac adapter (wall wart), thus the 'in'. It's not supposed to supply power to your accelerometer. Please post your project pic.

I am new to arduino and electronics, so i am learning as i go. I will change the power to 3.3V. I don't have a camera to post pictures.

uink:
I am new to arduino and electronics, so i am learning as i go. I will change the power to 3.3V. I don't have a camera to post pictures.

You will also need to connect 3.3V to aref pin on arduino and run the following in setup so your accelerometer reading (0-3.3V range) will still be mapped to (0-1023) and the mid points will be around 500.

analogReference(EXTERNAL);