Pages: [1]   Go Down
Author Topic: Grove I2C 3-axis Accelerometer troubles  (Read 580 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I'm trying to use the Grove I2C 3-axis accelerometer with Arduino UNO (sketch and phtoto is in the attachment).
It works fine for several iterations (usually about 100-200)
Then it stops sending data. smiley-cry

I've tryed to use accelerometer with and without pull-up resistors, but result is exactly the same.'

Where is the root of the problem?

Thanks for advance.

* accel.ino (1.77 KB - downloaded 5 times.)

* accel i2c wire.jpg (420.17 KB, 1600x1200 - viewed 20 times.)
Logged

0
Offline Offline
Shannon Member
****
Karma: 160
Posts: 10416
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please use code tags for code.  (The # button when composing a posting)


Code:
  while(Wire.available()) {
    if(count < 3) {
      while ( val[count] > 63 )  // reload the damn thing it is bad
      {
        val[count] = Wire.read();
      }
      count++;
    }
  }

That code will call Wire.read() when nothing is available to read.   You are not guarding the calls to read() properly.
« Last Edit: April 23, 2012, 11:26:14 am by MarkT » Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: