I’ m new in “Arduino programing”, I have " Arduino Duemilianove". I want to measuring acceleration with ADXl202, but the problem is …i cant interfacing the ADXL202 with uC ATmega328. If somebody can help me,with a good code, or… Thank u! Litel cod here…where I try to do this. U can contact me at e-mail adress also. Thank u again. Have a nice day!

ADXL202 code.txt (3.18 KB)

You must like spam! What is the problem?

printDouble only really works well if you pass it a double parameter (which you aren't doing). (and on the Arduino, double is the same as float)

Personally, I'd get rid of the LCD, and just use the serial monitor until I'd got the accelerometer working.

 accelerationX = (raportX - 500) *8; //acceleratia pe X
    accelerationX = digitalRead(xPin);

What's that supposed to do?

For persistent variables like your totals, you need to change their scope to global.

As a courtesy, it is preferable if you get rid of all the commented-out code before posting.

What is wrong with the example code supplied with the version 022 compiler?

It worked fine for me.

I want to read and measuring the duty cycle for can calculate acceleration like here ,then with LCD visualization that values. With this code my LCD displays “-4000.0” on both axes. I try exemple with “Memsic 2125 Accelerometer” from arduino exemples, and there LCD displays 0 and 1 :(. I dont now how to do !!
Here is a last version for this code! Thank u 4 attention! :slight_smile:

NEW ADXL202 code.txt (2.13 KB)

You’re still providing printDouble with “int” arguments.

What is this:

   accelerationX = digitalRead(xPin);

supposed to do? (I think I’ve already asked, but just to be sure, I’ll try one more time)

This is how I read your code:

  int T1X = pulseIn(xPin,HIGH);  
   int T1Y = pulseIn(yPin,HIGH);  
   int T2X = pulseIn(xPin,LOW);  //I dont now if is necesary to measuring and T2  
   int T2Y = pulseIn(yPin,LOW);	//for now what is the  period when pulse is LOW, 
  				//because in data sheet T is 1...10 ms
   int TX = T1X + T2X; 
   int TY = T1Y + T2Y; 
   int raportX = T1X/TX; 
   int raportY = T1Y/TY;   
   int accelerationX = (raportX - 500) *8; 
   int accelerationY = (raportY - 500) *8; 
    accelerationX = digitalRead(xPin);

    accelerationX = (raportX - 500) *8; 
    accelerationY = digitalRead(yPin);
    accelerationY = (raportY - 500) *8;

ok. so in this code :read "accelerationX" and with digitalWrite() I want to send to xPin value of accelerationX , to LCD. I dont now if is 100 % OK :( or my interpretation isn't ok. :|

I want to send to xPin value of accelerationX

You can't send an (effectively) analogue value to a digital pin - that doesn't make sense. All that digitalWrite will do is send zero (iff accelerationX == 0) or one (if accelerationX != 0)

OK, understand, can u write me a parth of code where read the values of this sensor ADXL202, for initialisation corect my application.? If u can, and have a time, of course :)

Reply #2 suggests there already is example code (I don’t use 022)