Using ADLX335(accelerometer) to light different LEDs depending on position

I have recently bought my MEGA arduino super kit. I have finished the lesson with my accelerometer. The code prints a value on the serial monitor.For example, if I move the accelerometer up, the y value increases. What I want to do is turn on a green LED only when the y value goes above 5. And I want it to turn off when it goes below 5. I know how to connect all the components but don't fully understand how to code. I have included lesson 15 (using the ADLX335 accelerometer) code below. How should I manipulate that code to turn on my green led? /* ADXL335 note:vcc-->5v ,but ADXL335 Vs is 3.3V The circuit: 5V: VCC analog 0: x-axis analog 1: y-axis analog 2: z-axis */ const int xpin = A0; // x-axis of the accelerometer const int ypin = A1; // y-axis const int zpin = A2; // z-axis (only on 3-axis models) void setup() { // initialize the serial communications: Serial.begin(9600); } void loop() { int x = analogRead(xpin); //read from xpin delay(1); // int y = analogRead(ypin); //read from ypin delay(1); int z = analogRead(zpin); //read from zpin

float zero_G = 512.0; //ADC is 0~1023 the zero g output equal to Vs/2 //ADXL335 power supply by Vs 3.3V float scale = 102.3; //ADXL335330 Sensitivity is 330mv/g //330 * 1024/3.3/1000

/Serial.print(x); Serial.print("\t"); Serial.print(y); Serial.print("\t"); Serial.print(z); Serial.print("\n");/ Serial.print(((float)x - 331.5)/65*9.8); //print x value on serial monitor Serial.print("\t"); Serial.print(((float)y - 329.5)/68.5*9.8); //print y value on serial monitor Serial.print("\t"); Serial.print(((float)z - 340)/68*9.8); //print z value on serial monitor Serial.print("\n"); delay(1000); //wait for 1 second }

"What I want to do is turn on a green LED only when the y value goes above 5. And I want it to turn off when it goes below 5"

if (y > 5)
{
  digitalWrite(yLED, HIGH);
}
else   // it's NOT > 5 so...
{
  digitalWrite(yLED, LOW);
}

You have to declare a pin as an output and assign it the alias "yLED".

Accelerometers are not position sensors. Your 5, is it a position? It will be very arbitrary if you try using accelerometer to determine it.

I don't know what sort the OP's is, but if it's like the Esplora's then it's a "pitch, roll and tilt" (??) sensor, different from a G's sensor.