Reliability Test: Uno R3 + Grove Accelerometer ADXL345 (±16g) + Grove Chainable RGB LED

Written by  on April 29, 2014 

* A log of reliability tests and subsequent findings when working with the Uno R3, Grove Accelerometer ADXL345 and Grove Chainable RGB LED *

I’ve switched to the ADXL345 after finding the MMA7660FC buggy. The ADXL has got a bigger range of measurement than the MMA but it will work for what I need. Also added a few more RGB LEDs.

—————————-

Setup:
Arduino IDE 1.5.6-r2
Arduino Uno r3
Grove base shield 1.3
Grove Accelerometer ADXL345 (±16g) on I2C
6 x Grove Chainable RGB LED on digital pins 2,3

Attached but not used:
Arduino Wifi shield updated with the firmware that comes with Arduino IDE 1.5.6-r2

—————————-

Test A: Reliability test of the grove digital accelerometer +-16g ADXL345.
Running example code from the latest github version (v1.1) Only modification is adding runcount and the IDE requested I do a ‘fix enconding and reload’ to make it UTF8.

– Result 1
Moved the accelerometer around a bunch intermittently, otherwise left it.
Still running at 18 minutes, count 2000
Good result

!! CHANGE – changed the delay to 50

– Result 2
Moved acc around a bunch intermittently
Still running at 15 minutes.
Looking through serial monitor runcount got to 6629 and went back to 1 though, does that mean the uno reset by itself? Long should go to 2 billion, no need to flick over at 6629. Maybe it was host computer going to sleep? I did go eat lunch while that was happening. Try one more time

– Result 3
Moved acc around a bunch intermittently
Still running at 33 minutes, 18000 count. 50ms delay.
Good result

==== Conclusion ====
The Grove ADXL345 is reliable so far.

Final Sketch:

*****************************************************************************/
//ADXL345 reliability test. Same as demo code plus runcounter. .
/*******************************************************************************/

#include <Wire.h>
#include <ADXL345.h>


ADXL345 adxl; //variable adxl is an instance of the ADXL345 library
long runcount = 0;

void setup(){
  Serial.begin(9600);
  adxl.powerOn();

  //set activity/ inactivity thresholds (0-255)
  adxl.setActivityThreshold(75); //62.5mg per increment
  adxl.setInactivityThreshold(75); //62.5mg per increment
  adxl.setTimeInactivity(10); // how many seconds of no activity is inactive?
 
  //look of activity movement on this axes - 1 == on; 0 == off 
  adxl.setActivityX(1);
  adxl.setActivityY(1);
  adxl.setActivityZ(1);
 
  //look of inactivity movement on this axes - 1 == on; 0 == off
  adxl.setInactivityX(1);
  adxl.setInactivityY(1);
  adxl.setInactivityZ(1);
 
  //look of tap movement on this axes - 1 == on; 0 == off
  adxl.setTapDetectionOnX(0);
  adxl.setTapDetectionOnY(0);
  adxl.setTapDetectionOnZ(1);
 
  //set values for what is a tap, and what is a double tap (0-255)
  adxl.setTapThreshold(50); //62.5mg per increment
  adxl.setTapDuration(15); //625us per increment
  adxl.setDoubleTapLatency(80); //1.25ms per increment
  adxl.setDoubleTapWindow(200); //1.25ms per increment
 
  //set values for what is considered freefall (0-255)
  adxl.setFreeFallThreshold(7); //(5 - 9) recommended - 62.5mg per increment
  adxl.setFreeFallDuration(45); //(20 - 70) recommended - 5ms per increment
 
  //setting all interrupts to take place on int pin 1
  //I had issues with int pin 2, was unable to reset it
  adxl.setInterruptMapping( ADXL345_INT_SINGLE_TAP_BIT,   ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_DOUBLE_TAP_BIT,   ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_FREE_FALL_BIT,    ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_ACTIVITY_BIT,     ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_INACTIVITY_BIT,   ADXL345_INT1_PIN );
 
  //register interrupt actions - 1 == on; 0 == off  
  adxl.setInterrupt( ADXL345_INT_SINGLE_TAP_BIT, 1);
  adxl.setInterrupt( ADXL345_INT_DOUBLE_TAP_BIT, 1);
  adxl.setInterrupt( ADXL345_INT_FREE_FALL_BIT,  1);
  adxl.setInterrupt( ADXL345_INT_ACTIVITY_BIT,   1);
  adxl.setInterrupt( ADXL345_INT_INACTIVITY_BIT, 1);
}

void loop(){
  
        runcount = runcount ++; 
  
	//Boring accelerometer stuff   
	int x,y,z;  
	adxl.readXYZ(&x, &y, &z); //read the accelerometer values and store them in variables  x,y,z
	// Output x,y,z values 
	Serial.print("values of X , Y , Z: ");
	Serial.print(x);
	Serial.print(" , ");
	Serial.print(y);
	Serial.print(" , ");
	Serial.println(z);
	
	double xyz[3];
	double ax,ay,az;
	adxl.getAcceleration(xyz);
	ax = xyz[0];
	ay = xyz[1];
	az = xyz[2];
	Serial.print("X=");
	Serial.print(ax);
    Serial.println(" g");
	Serial.print("Y=");
	Serial.print(ay);
    Serial.println(" g");
	Serial.print("Z=");
	Serial.println(az);
    Serial.println(" g");
	Serial.println("**********************");

    Serial.print("Runcount = ");
	Serial.println(runcount);

	delay(500);
 
}

———————————

Test B – Adding RGB Leds into the mix with the ADXL345. 6 chainable grove RGB Leds on D2/3. The LEDs use the Grove Chainable RGB LED library from here

– Result 1
Only the first 3 Leds worked. Looking at the serial output it was also noticeably slower. Guess it takes time to cycle through setting all the LEDs. With 24 on the final project that could take quite a while to set. Something to keep in mind. Still, arduinos can theoretically write the pixels for a whole screen, can’t take that long to write 7 pixels.

!! Learning the hard way: – code looks ok. Tried rearranging the LEDS, maybe one in the chain is bad. Hotpluging makes them unhappy. Any change (while done properly powered down) results in only 3 working. AhLooks like I just mixed up the ins and outs on the bottom. They have to chain together in a specific direction via marked in/out connectors

NOTE TO SELF – If you are using a buckled Grove connector don’t wiggle it as you pull it out. You’ll just break the solder holding the whole connector to the board. Hold the buckle open and pull straight. Also for this reason maybe don’t use the buckle connectors when prototyping and connecting/disconnecting a lot. Guess thats why they dont come standard.

– Result 2
It was the in/outs, man I’m stupid. Gotta wire it as according to the labels. The first 5 LED then behaved but the 6th Led was flickering. Replaced the LED and still flickering. Replaced the cable with a slighly shorter cable and fixed. Suspect we are running up against a power issue OR it was just one bad cable

!! Change – added a 7th led, totally new led, totally new cable.

– Result 3 (7 Leds, Acc, Delay 50)
Seven leds works fine. It Must have been a bad cable. Binned and moved on.
Lets open the serial monitor and go for the reliability test.

– Result 4
I intermittently moved the accelerometer around.
Still working well after 5+ minutes and 3500 iterations.
Good result.

!! change – lowered the delay even further, down to 10. See if this can compensate for increased latency from increased LED numbers (Should I just whack all 24 Leds on it? then I’m dealing with the full amount I’ll need for this project). Also increased the baud rate for the serial to 19200 , could this be a choke point? I don’t even know.

!! QUESTION: work out how serial monitor baud rate relates to the milisecond delay times you set in Arduino. Will a 9600 baud rate ever ‘hold back’ the program?

– Result 5 (7 Leds, Acc, Delay 10, Baud 19200)
Serial monitor didn’t ‘feel’ any faster. If we can keep this speed as the reporting rate for the accelerometer that will be fine however I’m concerned this won’t be anywhere near fast enough to smoothly dim the LEDs. They are a little bit choppy looking and they’re are only 6.
I intermittently moved the accelerometer around.
Still working after 10 minutes and 5500 iterations.
Good result.

==== Conclusion ====
The Grove ADXL345 plus 6 x Grove Chainable RGB LED seems reliable so far.

Final Sketch:

  
/*****************************************************************************/
//ADXL345 reliability test plus chainable LED cycle through.
//Based on ADXL345 and Grove Chainable RGB LED demos by SEEED studio
// buildlog.tobyk.com.au 
/*******************************************************************************/

// Acc include and variables
#include <Wire.h>
#include <ADXL345.h>
ADXL345 adxl; //variable adxl is an instance of the ADXL345 library

// LED include and variables
#include <ChainableLED.h>
#define NUM_LEDS  6
ChainableLED leds(2, 3, NUM_LEDS);
byte pos = 0;

// Debug include and variables
long runcount = 0;

void setup(){
  //debug setup
  Serial.begin(19200);
  
  //acc setup 
  adxl.powerOn();

  //set activity/ inactivity thresholds (0-255)
  adxl.setActivityThreshold(75); //62.5mg per increment
  adxl.setInactivityThreshold(75); //62.5mg per increment
  adxl.setTimeInactivity(10); // how many seconds of no activity is inactive?
 
  //look of activity movement on this axes - 1 == on; 0 == off 
  adxl.setActivityX(1);
  adxl.setActivityY(1);
  adxl.setActivityZ(1);
 
  //look of inactivity movement on this axes - 1 == on; 0 == off
  adxl.setInactivityX(1);
  adxl.setInactivityY(1);
  adxl.setInactivityZ(1);
 
  //look of tap movement on this axes - 1 == on; 0 == off
  adxl.setTapDetectionOnX(0);
  adxl.setTapDetectionOnY(0);
  adxl.setTapDetectionOnZ(1);
 
  //set values for what is a tap, and what is a double tap (0-255)
  adxl.setTapThreshold(50); //62.5mg per increment
  adxl.setTapDuration(15); //625us per increment
  adxl.setDoubleTapLatency(80); //1.25ms per increment
  adxl.setDoubleTapWindow(200); //1.25ms per increment
 
  //set values for what is considered freefall (0-255)
  adxl.setFreeFallThreshold(7); //(5 - 9) recommended - 62.5mg per increment
  adxl.setFreeFallDuration(45); //(20 - 70) recommended - 5ms per increment
 
  //setting all interrupts to take place on int pin 1
  //I had issues with int pin 2, was unable to reset it
  adxl.setInterruptMapping( ADXL345_INT_SINGLE_TAP_BIT,   ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_DOUBLE_TAP_BIT,   ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_FREE_FALL_BIT,    ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_ACTIVITY_BIT,     ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_INACTIVITY_BIT,   ADXL345_INT1_PIN );
 
  //register interrupt actions - 1 == on; 0 == off  
  adxl.setInterrupt( ADXL345_INT_SINGLE_TAP_BIT, 1);
  adxl.setInterrupt( ADXL345_INT_DOUBLE_TAP_BIT, 1);
  adxl.setInterrupt( ADXL345_INT_FREE_FALL_BIT,  1);
  adxl.setInterrupt( ADXL345_INT_ACTIVITY_BIT,   1);
  adxl.setInterrupt( ADXL345_INT_INACTIVITY_BIT, 1);
}

void loop(){
        // debug actions
        runcount = runcount ++; 
  
        // led actions
         for (byte i=0; i<NUM_LEDS; i++)
        {
        if (i==pos)
        leds.setColorRGB(i, 255, 0, 0);  
        else
        leds.setColorRGB(i, 0, 0, 255); 
          }
  
        pos = (pos+1) % NUM_LEDS;
  
	//acc actions
	int x,y,z;  
	adxl.readXYZ(&x, &y, &z); //read the accelerometer values and store them in variables  x,y,z
	// Output x,y,z values 
	Serial.print("values of X , Y , Z: ");
	Serial.print(x);
	Serial.print(" , ");
	Serial.print(y);
	Serial.print(" , ");
	Serial.println(z);
	
	double xyz[3];
	double ax,ay,az;
	adxl.getAcceleration(xyz);
	ax = xyz[0];
	ay = xyz[1];
	az = xyz[2];
	Serial.print("X=");
	Serial.print(ax);
    Serial.println(" g");
	Serial.print("Y=");
	Serial.print(ay);
    Serial.println(" g");
	Serial.print("Z=");
	Serial.println(az);
    Serial.println(" g");
	Serial.println("**********************");

    Serial.print("Runcount = ");
	Serial.println(runcount);

        // the all important delay
	delay(10);
 
}

———————————-

Test C – As before but going to take it to the full 24 LEDs. Just to see what happens.

– Result 1
Ok it works but super slow. Literally a second between them changing when they should change instantly. Realistically its updating all 24 of them every time but should be faster than this. Hardly practical. Will try a few of the other LED demos and see if they work better by doing things in a different way

!! Change – Try the grove chainable LED Demos

– Result 2:
All LED demos perform badly with 24x LEDs. You can clearly see the colour change move up the chain.

??? conjecture: It’s slow because it doesn’t have enough power to deal with them all? But if you reduce the number to control down to 3, but still have 24 connected then it’s smooth and fast. So prob not that.

????conjecture 2: It’s something in the chainable RGB LED library that’s slow. Look in the datasheet for a way to do it faster. Don’t have the time right now.

???? Research: Plenty of youtube videos of LED strips running on P9813 protocol at perfectly acceptable speeds. DMX to p9813 convertors exist. Not sure what the problem is.
Damn thing seems faster now that its been on a while too…

Could split controlling them over several digital pin pairs. 6 groups of 4. Will you have enough with the wifi and acc?
Can use 0,1 2,3 5,6 8,9 And then A0,A1 A2,A3 if you set them as outputs? Don’t really want to use this many pins though.

===== Conclusion =====
There is something wrong with the current version of the Grove Chainable RGB LED library (as of 20/04/14). It should be able to perform a lot faster.

————————————

Test C – Use a different method to access the Grove Chainable RGB LEDs, not the default library. See if you can get speed improvements. Used the method at http://www.evola.fr/en/chainable-rgb-led-p-163.html?osCsid=o8kfiok52urd5it8uoc6hfrq1l5h34a1 modified to manually code 24 values
Sketch:

#define uint8 unsigned char
#define uint16 unsigned int
#define uint32 unsigned long int
 
// connection digital pins 0 and 1
int Clkpin = 2;
int Datapin = 3;

// Clock
void ClkProduce(void) {
  digitalWrite(Clkpin, LOW);
  delayMicroseconds(20);
  digitalWrite(Clkpin, HIGH);
  delayMicroseconds(20);   
}

// 32 bits zero (initialization and update)
void Send32Zero(void) {
    unsigned char i;
    for (i=0; i<32; i++) {
          digitalWrite(Datapin, LOW);
          ClkProduce();
    }
}

// Calibration bits
uint8 TakeAntiCode(uint8 dat) {
    uint8 tmp = 0;
    if ((dat & 0x80) == 0) {
        tmp |= 0x02;
    }
    if ((dat & 0x40) == 0) {
        tmp |= 0x01;
    }
    return tmp;
}
 
// Gray scale data
void DatSend(uint32 dx) {
    uint8 i;
    for (i=0; i<32; i++) {
        if ((dx & 0x80000000) != 0) {
               digitalWrite(Datapin, HIGH);
        }
        else {
               digitalWrite(Datapin, LOW);
        }
        dx <<= 1;
        ClkProduce();
    }
}
 
// data processing
void DataDealWithAndSend(uint8 r, uint8 g, uint8 b)
{
    uint32 dx = 0;
 
    dx |= (uint32)0x03 << 30;  // highest two bits 1,flag bits
    dx |= (uint32)TakeAntiCode(b) << 28;
    dx |= (uint32)TakeAntiCode(g) << 26;    
    dx |= (uint32)TakeAntiCode(r) << 24;
 
    dx |= (uint32)b << 16;
    dx |= (uint32)g << 8;
    dx |= r;
 
    DatSend(dx);
}
 
void setup()  {
  pinMode(Datapin, OUTPUT);
  pinMode(Clkpin, OUTPUT);
}
 
void loop()  {
  int i;
 
      Send32Zero(); // Initialization
      DataDealWithAndSend(0, 255, 0); // 1
      DataDealWithAndSend(255, 0, 0); // 2
      DataDealWithAndSend(255, 0, 255); // 3 
      DataDealWithAndSend(255, 255, 0); // 4
      DataDealWithAndSend(0, 255, 255); // 5
      DataDealWithAndSend(255, 255, 0); // 6
      DataDealWithAndSend(255, 255, 0); // 7
      DataDealWithAndSend(0, 255, 255); // 8
      DataDealWithAndSend(0, 255, 0); // 9
      DataDealWithAndSend(255, 255, 0); // 10
      DataDealWithAndSend(255, 0, 255); // 11
      DataDealWithAndSend(255, 255, 255); // 12
      DataDealWithAndSend(255, 0, 255); // 13
      DataDealWithAndSend(0, 255, 0); // 14
      DataDealWithAndSend(255, 0, 255); // 15
      DataDealWithAndSend(255, 0, 128); // 16
      DataDealWithAndSend(255, 0, 255); // 17
      DataDealWithAndSend(0, 0, 255); // 18
      DataDealWithAndSend(255, 0, 255); // 19
      DataDealWithAndSend(255, 0, 0); // 20
      DataDealWithAndSend(0, 0, 255); // 21
      DataDealWithAndSend(255, 0, 255); // 22
      DataDealWithAndSend(0, 255, 0); // 23
      DataDealWithAndSend(0, 255, 0); // 24
      Send32Zero();  // Update datas 
    delay(10);

// New sequence
      Send32Zero();
      DataDealWithAndSend(255, 0, 0); // 1
      DataDealWithAndSend(0, 0, 255); // 2
      DataDealWithAndSend(0, 255, 255); // 3 
      DataDealWithAndSend(255, 0, 0); // 4
      DataDealWithAndSend(0, 0, 255); // 5
      DataDealWithAndSend(0, 255, 255); // 6
      DataDealWithAndSend(255, 0, 0); // 7
      DataDealWithAndSend(0, 0, 255); // 8
      DataDealWithAndSend(0, 255, 255); // 9
      DataDealWithAndSend(255, 0, 0); // 10
      DataDealWithAndSend(0, 0, 255); // 11
      DataDealWithAndSend(0, 255, 255); // 12
      DataDealWithAndSend(255, 0, 0); // 13
      DataDealWithAndSend(0, 0, 255); // 14
      DataDealWithAndSend(0, 255, 255); // 15
      DataDealWithAndSend(255, 0, 0); // 16
      DataDealWithAndSend(0, 0, 255); // 17
      DataDealWithAndSend(0, 255, 255); // 18
      DataDealWithAndSend(255, 0, 0); // 19
      DataDealWithAndSend(0, 0, 255); // 20
      DataDealWithAndSend(0, 255, 255); // 21
      DataDealWithAndSend(255, 0, 0); // 22
      DataDealWithAndSend(0, 0, 255); // 23
      DataDealWithAndSend(0, 255, 255); // 24      
      Send32Zero();      
    delay(10);    
 
      Send32Zero();
     DataDealWithAndSend(255, 0, 255); // 1
      DataDealWithAndSend(255, 0, 0); // 2
      DataDealWithAndSend(255, 0, 255); // 3 
      DataDealWithAndSend(255, 0, 255); // 4
      DataDealWithAndSend(255, 0, 255); // 5
      DataDealWithAndSend(255, 0, 255); // 6
      DataDealWithAndSend(255, 0, 255); // 7
      DataDealWithAndSend(255, 0, 255); // 8
      DataDealWithAndSend(255, 0, 255); // 9
      DataDealWithAndSend(255, 0, 255); // 10
      DataDealWithAndSend(255, 0, 255); // 11
      DataDealWithAndSend(255, 0, 255); // 12
      DataDealWithAndSend(255, 0, 255); // 13
      DataDealWithAndSend(255, 0, 255); // 14
      DataDealWithAndSend(255, 0, 255); // 15
      DataDealWithAndSend(255, 0, 255); // 16
      DataDealWithAndSend(255, 0, 255); // 17
      DataDealWithAndSend(255, 0, 255); // 18
      DataDealWithAndSend(255, 0, 255); // 19
      DataDealWithAndSend(255, 0, 255); // 20
      DataDealWithAndSend(255, 0, 255); // 21
      DataDealWithAndSend(255, 0, 255); // 22
      DataDealWithAndSend(255, 0, 255); // 23
      DataDealWithAndSend(255, 0, 255); // 24    
      Send32Zero();      
    delay(10);
}														
																				 

– – Result 1
Great! LEDs change instantly.

!! Change – Make the same demo use a for loop.
Sketch: LED_Speed_Test_FOR

#define uint8 unsigned char
#define uint16 unsigned int
#define uint32 unsigned long int
#define NUM_LEDS  24 
 
// connection digital pins 2 and 3
int Clkpin = 2;
int Datapin = 3;

// Clock
void ClkProduce(void) {
  digitalWrite(Clkpin, LOW);
  delayMicroseconds(20);
  digitalWrite(Clkpin, HIGH);
  delayMicroseconds(20);   
}

// 32 bits zero (initialization and update)
void Send32Zero(void) {
    unsigned char i;
    for (i=0; i<32; i++) {
          digitalWrite(Datapin, LOW);
          ClkProduce();
    }
}

// Calibration bits
uint8 TakeAntiCode(uint8 dat) {
    uint8 tmp = 0;
    if ((dat & 0x80) == 0) {
        tmp |= 0x02;
    }
    if ((dat & 0x40) == 0) {
        tmp |= 0x01;
    }
    return tmp;
}
 
// Gray scale data
void DatSend(uint32 dx) {
    uint8 i;
    for (i=0; i<32; i++) {
        if ((dx & 0x80000000) != 0) {
               digitalWrite(Datapin, HIGH);
        }
        else {
               digitalWrite(Datapin, LOW);
        }
        dx <<= 1;
        ClkProduce();
    }
}
 
// data processing
void DataDealWithAndSend(uint8 r, uint8 g, uint8 b)
{
    uint32 dx = 0;
 
    dx |= (uint32)0x03 << 30;  // highest two bits 1,flag bits
    dx |= (uint32)TakeAntiCode(b) << 28;
    dx |= (uint32)TakeAntiCode(g) << 26;    
    dx |= (uint32)TakeAntiCode(r) << 24;
 
    dx |= (uint32)b << 16;
    dx |= (uint32)g << 8;
    dx |= r;
 
    DatSend(dx);
}
 
void setup()  {
  pinMode(Datapin, OUTPUT);
  pinMode(Clkpin, OUTPUT);
}
 
void loop()  {

 int x = 1  
 for (int i = 0; i > -1; i = i + x){
      
                  // switch direction at peak
      
   
 
      Send32Zero(); // Initialization
      
      for (byte n = 0; n<NUM_LEDS; n++){
      DataDealWithAndSend(0, i, 0); 
      }
      
      Send32Zero();  // Update datas 
    
       if (i == 255) x = -1; 
    
    delay(10);
 }      

}														
																				 

-Result 2
– Also great. Ok, use this new code for the LEDs. It seems to be more light weight than the old library anyway.

==== Conclusion ====
The code here is much faster at changing the state of the Grove Chainable RGB LED than the Seeed Studio github code.

————–
Test D – Finally, the reliability test for the combined hardware – ADXL345 accelormeter spitting out over serial plus Grove RGB LEDs cycling through a rainbow effect.

						

// Acc declarations
#include <Wire.h>
#include <ADXL345.h>


// RGB declarations
#define uint8 unsigned char
#define uint16 unsigned int
#define uint32 unsigned long int
#define NUM_LEDS  24 
int Clkpin = 2;
int Datapin = 3;
int i = 1;
byte q = 1; 

ADXL345 adxl; //variable adxl is an instance of the ADXL345 library


// Debug declarations
long runcount = 0;

// Clock function (RGB) 
void ClkProduce(void) {
  digitalWrite(Clkpin, LOW);
  delayMicroseconds(20);
  digitalWrite(Clkpin, HIGH);
  delayMicroseconds(20);   
}

// 32 bits zero (initialization and update function (RGB)
void Send32Zero(void) {
    unsigned char i;
    for (i=0; i<32; i++) {
          digitalWrite(Datapin, LOW);
          ClkProduce();
    }
}

// Calibration bits function (RGB) 
uint8 TakeAntiCode(uint8 dat) {
    uint8 tmp = 0;
    if ((dat & 0x80) == 0) {
        tmp |= 0x02;
    }
    if ((dat & 0x40) == 0) {
        tmp |= 0x01;
    }
    return tmp;
}
 
// Gray scale data function (RGB) 
void DatSend(uint32 dx) {
    uint8 i;
    for (i=0; i<32; i++) {
        if ((dx & 0x80000000) != 0) {
               digitalWrite(Datapin, HIGH);
        }
        else {
               digitalWrite(Datapin, LOW);
        }
        dx <<= 1;
        ClkProduce();
    }
}
 
// data processing function (RGB) 
void DataDealWithAndSend(uint8 r, uint8 g, uint8 b)
{
    uint32 dx = 0;
 
    dx |= (uint32)0x03 << 30;  // highest two bits 1,flag bits
    dx |= (uint32)TakeAntiCode(b) << 28;
    dx |= (uint32)TakeAntiCode(g) << 26;    
    dx |= (uint32)TakeAntiCode(r) << 24;
 
    dx |= (uint32)b << 16;
    dx |= (uint32)g << 8;
    dx |= r;
 
    DatSend(dx);
}
 
void setup()  {
  //debug setup
  Serial.begin(19200);
  
  //RGB setup
  pinMode(Datapin, OUTPUT);
  pinMode(Clkpin, OUTPUT);
  
  //rest is Acc setup
  //acc setup 
  adxl.powerOn();

  //set activity/ inactivity thresholds (0-255)
  adxl.setActivityThreshold(75); //62.5mg per increment
  adxl.setInactivityThreshold(75); //62.5mg per increment
  adxl.setTimeInactivity(10); // how many seconds of no activity is inactive?
 
  //look of activity movement on this axes - 1 == on; 0 == off 
  adxl.setActivityX(1);
  adxl.setActivityY(1);
  adxl.setActivityZ(1);
 
  //look of inactivity movement on this axes - 1 == on; 0 == off
  adxl.setInactivityX(1);
  adxl.setInactivityY(1);
  adxl.setInactivityZ(1);
 
  //look of tap movement on this axes - 1 == on; 0 == off
  adxl.setTapDetectionOnX(0);
  adxl.setTapDetectionOnY(0);
  adxl.setTapDetectionOnZ(1);
 
  //set values for what is a tap, and what is a double tap (0-255)
  adxl.setTapThreshold(50); //62.5mg per increment
  adxl.setTapDuration(15); //625us per increment
  adxl.setDoubleTapLatency(80); //1.25ms per increment
  adxl.setDoubleTapWindow(200); //1.25ms per increment
 
  //set values for what is considered freefall (0-255)
  adxl.setFreeFallThreshold(7); //(5 - 9) recommended - 62.5mg per increment
  adxl.setFreeFallDuration(45); //(20 - 70) recommended - 5ms per increment
 
  //setting all interrupts to take place on int pin 1
  //I had issues with int pin 2, was unable to reset it
  adxl.setInterruptMapping( ADXL345_INT_SINGLE_TAP_BIT,   ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_DOUBLE_TAP_BIT,   ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_FREE_FALL_BIT,    ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_ACTIVITY_BIT,     ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_INACTIVITY_BIT,   ADXL345_INT1_PIN );
 
  //register interrupt actions - 1 == on; 0 == off  
  adxl.setInterrupt( ADXL345_INT_SINGLE_TAP_BIT, 1);
  adxl.setInterrupt( ADXL345_INT_DOUBLE_TAP_BIT, 1);
  adxl.setInterrupt( ADXL345_INT_FREE_FALL_BIT,  1);
  adxl.setInterrupt( ADXL345_INT_ACTIVITY_BIT,   1);
  adxl.setInterrupt( ADXL345_INT_INACTIVITY_BIT, 1);
}
 
void loop()  {

  //acc actions
	int x,y,z;  
	adxl.readXYZ(&x, &y, &z); //read the accelerometer values and store them in variables  x,y,z
	// Output x,y,z values 
	Serial.print("values of X , Y , Z: ");
	Serial.print(x);
	Serial.print(" , ");
	Serial.print(y);
	Serial.print(" , ");
	Serial.println(z);
	
	double xyz[3];
	double ax,ay,az;
	adxl.getAcceleration(xyz);
	ax = xyz[0];
	ay = xyz[1];
	az = xyz[2];
	Serial.print("X=");
	Serial.print(ax);
    Serial.println(" g");
	Serial.print("Y=");
	Serial.print(ay);
    Serial.println(" g");
	Serial.print("Z=");
	Serial.println(az);
    Serial.println(" g");
	Serial.println("**********************");

  
  // debug
  runcount = runcount ++; 
  Serial.print("Runcount = ");
  Serial.println(runcount);
  
  //rgb 
       
      if (i > 256) q = -1; 
      if (i < 0) q = 1;
      i = i + q; 
      Serial.println(i);
       
      Send32Zero(); // Initialization
      
      for (byte n = 0; n<NUM_LEDS; n++){
      DataDealWithAndSend(i, 0, 0); 
      }
      
      Send32Zero();  // Update datas 
    
    
    // all hail the delay
    delay(10);
      

}														 

– Result 1
I intermittently moved the accelerometer around.
Run for 10 minutes, 8500 runcount
Good, very reliable. (Although something wrong with my crappy LED fading code but the functionality is there)

==== Conclusion: ====
The combination of Uno R3 + 24 x Grove RGB LEDs + Grove ADXL345 Acc is reliable (at least for 10 minutes!)

What Next: Time to test the wifi shield.