Accelerometer 3-axes + BlinkM

Hi all,

I just received my Arduino and some other parts (BlinkM max, ADXL330..., I was wondering if there's any sample code to use my 3-axes Accelerometer to control the BlinkM script's or specific light color for each angle, like the wiichuck?

I understand most of the code, but linking things together is hard to me.

So please if there's any sample codes just to start it will be amazing.

PS: during shipping, I received my BlinkM max (led resistor damaged 30 ohm) and I didn't find the same, only 33 ohm, can I use it or it will affect the color?

Best regards, Sam

Hi Again,

Well i was trying from a while but no chance, please if some one can check my testing code, and tell me if i’m in the right way or not, i start to get color change but not in the way that i want…

I’m trying to get a specific color depend on Delta value… later on playing script but i don’t know how.

#include <Wire.h>
#define xPin 3
#define yPin 2
#define zPin 1
int x = 0;
int y = 0;
int z  = 0;
int delta = 0;

void setup()
{
  Serial.begin(9600);
  Wire.begin();
}
void loop() {
delta = x + y + z;
x = analogRead(xPin);
y = analogRead(yPin);
z = analogRead(zPin);
delta -= x + y + z;
Serial.print("X=");
Serial.print(x);
Serial.print(", ");
Serial.print("Y=");
Serial.print(y);
Serial.print(", ");
Serial.print("Z=");
Serial.print(z);
Serial.print(", ");
Serial.print("Delta=");
Serial.println(abs(delta));
delay(500);
if (delta <= 4){
Wire.beginTransmission(0x09);          // join I2C, talk to BlinkM 0x09  
Wire.send('n');              
Wire.send(0x33);
Wire.endTransmission();               // leave I2C bus
}
else {
Wire.beginTransmission(0x09);          // join I2C, talk to BlinkM 0x09 
Wire.send('n');             
Wire.send(0xcc);
Wire.endTransmission();               // leave I2C bus
}
}

Regards,
Sam