i want to disable the function of the accelerometer if I put an LED in A2 (analog output for Arduino Uno) which is in high condition... if it is low condition, the function of the accelerometer can function it back normally.. during high state i want the accelerometer to disable...
my problem is how to make a command to disable the function of the accelerometer... Is it possible to use an IF/ELSE statement here...
can anyone help me??? please...
this is the code for my accelerometer taken from the net...
const int groundpin = 18; // analog input pin 4 -- ground
const int powerpin = 19; // analog input pin 5 -- voltage
int xpin = A3; // x-axis of the accelerometer
int sensorValue = 0; // variable to store the value coming from the sensor
void setup()
{
// initialize the serial communications:
Serial.begin(9600);
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
}
void loop()
{
// read the value from the sensor:
sensorValue = analogRead(xpin);
// print the sensor values:
Serial.print(analogRead(xpin));
// print a tab between values:
Serial.print("\t");
Serial.println();
// delay before next reading:
delay(100);
}
Moderator edit:
[code] [/code] tags added.