Go Down

Topic: Problems with Wire.endTransmission() (Read 1 time) previous topic - next topic

Biagio

Hi everybody!
I'd like to read measurements form a digital accelerometer (ADXL345) that implements I2C with Arduino Mega, but I have some problems with the Wire library. Exactly, the "Wire.endTransmission()" command stops the program! I tried my code in another computer and it works properly, but in mine there's nothing to do. To explain better my problem, I'll post here an example code and the output it produces:

CODE:

#include <Wire.h>

void setup() {
Wire.begin();
Serial.begin(9600);
}

void loop() {
Wire.beginTransmission(0x53);
Serial.print("step 1\n");
Wire.endTransmission();
Serial.print("step 2");
Serial.print("\n");
delay(500);
}

OUTPUT:

step1

What should I do to fix this problem?
Thanks to everybody,
Biagio

Professor Chaos

#1
Oct 13, 2009, 02:33 am Last Edit: Oct 13, 2009, 02:34 am by lefstin Reason: 1
The code works for me (at least on a 328);  I get "step 1" and "step 2" printed on the serial monitor ad infinitum.  This is with nothing connected though.


methin

Hi,
I using the Arduino Mega and ADXL345 too. I find the same problem. I checked step by step program. It's alway stop at "Wire.endTransmission()" command. I don't know why.
So How can I to fix it. Please help.

thank for everyone helping.
Ping

wayoda

Hi,
Quote
I tried my code in another computer and it works properly

How are your two machines different ?
Operating  System?

Eberhard

wayoda

@biagio
You know that your code does not send any data to the device?
You have to send some register-data to the ADXL.
This is not a valid command for the device.  
Code: [Select]

Wire.beginTransmission(0x53);
Serial.print("step 1\n");
Wire.endTransmission();

Eberhard

Go Up