My accelerometer has been in a breadboard. The power is in the Vin pin, and the gnd is in the digital side. Is that OK? I have my x,y,and z in analog pins now. However, now my x axis is showing a reading of 0, regardless. I have two codes- one just for the readouts, and the other with an alarm. I was trying to get the plain code to work, so i could adapt it for my project, but it wasn't working. My alarm code, however, I have gotten to start working properly, so i will just use that for the time being.
The alarm code takes the difference (movement) of the adxls axis, and then prints low (normal) or high (moving), and lights the LED when it is on high.
Continuing the matter, i have a sensor system hooked up and running. What it does is if the two sensor values are above the alarmValue, it lights the LED. I am trying to add the adxl, so that when the two sensor values are above the alarmValue, and the adxl is on HIGH, the LED will light up. I'm not sure how to add the LED system in, because it is not based on an alarmValue.
Two sensor code
if (corda > alarmValue && toad > alarmValue)
{
digitalWrite (ledPin, HIGH); // turn the LED on
}
else
{
digitalWrite (ledPin, LOW);
}
How i tried to modify it...
// if ((ybase-ypin) >= 100) //makes the high, low signals
if ((abs(yy-ybase) >= diff) && (abs(zz-zbase)>= diff))
{
digitalWrite(xbackward, HIGH);
Serial.print("high= ybase \t");
Serial.print(yy-ybase);
//Serial.print( analogRead(ybase)-ypin);
Serial.print("cc \t");
//Serial.print(abs(zbase-zpin));
}
else
{
digitalWrite(xbackward, LOW);
Serial.print("low \t");
};
if (corda > alarmValue && toad > alarmValue && (xbackward, HIGH))
{
digitalWrite (ledPin, HIGH); // turn the LED on
}
else
{
digitalWrite (ledPin, LOW);