Bonsoir,
Alors voila j'ai acheté un arduino pour m' initié à l’électronique est j'ai voulu créer un montage ayant pour but d'allumer une lampe tant que l'arduino est en mouvement.
J'ai pour cela utiliser un shield à 4 relais et un accéléromètre MMA7361L, jusque la tout va bien
J'ai câblé comme le datasheet le montrer est la j'utilise un programme trouvé sur internet pour regardé se qu'il renvoi avec le moniteur série, et la catastrophe les données reste stable sur les trois axe j'ai beau l'agiter rien ne se passe:
int x,y,z;
float vx, vy, vz, gx, gy, gz;
void setup()
{
Serial.begin(9600);
analogReference(EXTERNAL); //set aref to 3.3v, if you use built in 3.3v for value, use a 15K resistor to limit current
}
void loop()
{
// Read in accelerometer values
x = analogRead(A0);
y = analogRead(A1);
z = analogRead(A2);
// Convert ADC values to voltages and G values
// The formula for voltage conversion is v = (ADCREAD*VREF/1023)-ZGV, where ZGV is "Zero-G voltage" (voltage at 0G)
// ZGV is found in the spec sheet and happens to be 1.5 in our case. Warning: you need to make the variable signed!
// The formula for G conversion is g = v/SENSITIVITY. The sensitvity is also found in the spec sheet and happens to be 800 mV/g here.
// Remember to make your units consistent! (g = v[V]*1000 / SEN [mV] )
vx = (x*3.3/1023)-1.65;
gx = vx*10/8;
vy = (y*3.3/1023)-1.65;
gy = vy*10/8;
vz = (z*3.3/1023)-1.65;
gz = vz*10/8;
Serial.print("vx=");
Serial.print(gx,DEC); // delet the dec?
Serial.print(" ");
Serial.print("vy=");
Serial.print(gy,DEC); //delete the dec?
Serial.print(" ");
Serial.print("vz=");
Serial.println(vz,DEC); //delete the dec?
delay(500);
}
Est voila se qu'il me renvoie:
vx=2.0625000000 vy=2.0625000000 vz=1.6500000000
vx=2.0625000000 vy=2.0625000000 vz=1.6500000000
Si une âme charitable pouvait m'aider s'il vous plaît.