user31142: Can anyone give me the full code of my project because my code is not working?
My aim is that when the Z axis of an accelerometer is below 370 and a pushbutton connected to a pin 2 becomes high, then pin 13 turns high and remains high.  When the Z axis is above 370 and pushbutton is high then the pin 13 goes low and remains low.
P.S I am also a noob to Arduino 
Here is my code :
const int ledPin = 13;        
const int threshold = 370;    
const int pull_up_resistor = 12;
const int pull_down_resistor = 11;
const int groundpin = A1;              
const int powerpin = A5;            
const int xpin = A2;                   
const int ypin = A3;                  
const int zpin = A4;  

int pushButton = 2;


void setup() {

  pinMode(ledPin, OUTPUT);

  Serial.begin(9600);

  Serial.begin(9600);

  pinMode(pushButton, INPUT);
  digitalWrite(pushButton, HIGH);
  Serial.begin(9600);


  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW);
  digitalWrite(powerpin, HIGH);
}


void loop() {

  int buttonState = digitalRead(pushButton);

  Serial.println(buttonState);
  delay(100);        // delay in between reads for stability

  Serial.print(analogRead(xpin));

  Serial.print("\t");
  delay(100);
  Serial.print(analogRead(ypin));

  Serial.print("\t");
  delay(100);
  Serial.print(analogRead(zpin));
  Serial.println();

  delay(100);

  if (buttonState = 0) {
    digitalWrite( ledPin, HIGH);
  }  
  if (buttonState = 1) {
    digitalWrite (pushButton, LOW);
  }  

}


user31030: Use some formatter before posting it here. For example here is great one, written by KrzaQ edit: didn't noticed that was fixed by Mark
Next thing to do is keep your code clean. Three times you initialized Serial communcation. Why? 
You should also first initalize Serial then set pinModes into state and then put digitalWrite. It helps reading the code.
Example:
Serial.begin(value);
pinMode(x,x);
pinMode(y,x);
pinMode(z,x);
digitalWrite(x,x);
digitalWrite(y,x);
digitalWrite(z,x);

More readable, isn't it?
Next step: Pull-up and pull-down resistors... It is not thing you need to set in your code. It is hardware connection of 1 resistor, sometimes capacitor and device. There is no use for it in your device.
Read about them here: Pull-up/pull-down
Next thing: You must not define your outputs as power pins and treat them like one. AVR's have limited power output from each pin and by doing so you can fry it very quickly.
If I understand your sentence correctly you need to save your angle values into variable like this (pseudo code, you have to adjust it to your case no one will write it for free):
int xvalue, yvalue, zvalue, button;
void setup(); // all setup should go here do not skip this like me here
void loop() {
  xvalue = analogRead(xpin);
  yvalue = analogRead(ypin);
  zvalue = analogRead(zpin);
  if (button == 1) {
    if (zvalue > 370)
      digitalWrite(ledPin, HIGH);
    else
      digitalWrite(ledPin, LOW);
  } else
    actionWhenPushButtonIsZero();
}

If you think about what I wrote and focus on your task I am sure that everything will work in your device. THINK first then ask next questions.

31142: <p>Can anyone give me the full code of my project because my code is not working?</p>

<p>My aim is that when the Z axis of an accelerometer is below 370 and a pushbutton connected to a pin 2 becomes high, then pin 13 turns high and remains high.  When the Z axis is above 370 and pushbutton is high then the pin 13 goes low and remains low.</p>

<p>P.S I am also a noob to Arduino </p>

<p>Here is my code :</p>

<pre><code>const int ledPin = 13;        
const int threshold = 370;    
const int pull_up_resistor = 12;
const int pull_down_resistor = 11;
const int groundpin = A1;              
const int powerpin = A5;            
const int xpin = A2;                   
const int ypin = A3;                  
const int zpin = A4;  

int pushButton = 2;


void setup() {

  pinMode(ledPin, OUTPUT);

  Serial.begin(9600);

  Serial.begin(9600);

  pinMode(pushButton, INPUT);
  digitalWrite(pushButton, HIGH);
  Serial.begin(9600);


  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW);
  digitalWrite(powerpin, HIGH);
}


void loop() {

  int buttonState = digitalRead(pushButton);

  Serial.println(buttonState);
  delay(100);        // delay in between reads for stability

  Serial.print(analogRead(xpin));

  Serial.print("\t");
  delay(100);
  Serial.print(analogRead(ypin));

  Serial.print("\t");
  delay(100);
  Serial.print(analogRead(zpin));
  Serial.println();

  delay(100);

  if (buttonState = 0) {
    digitalWrite( ledPin, HIGH);
  }  
  if (buttonState = 1) {
    digitalWrite (pushButton, LOW);
  }  

}
</code></pre>
 31030: <p>Use some formatter before posting it here. For example here is great one, written by <a href="http://format.krzaq.cc/" rel="nofollow noreferrer">KrzaQ</a> edit: didn't noticed that was fixed by Mark</p>

<p>Next thing to do is keep your code clean. Three times you initialized Serial communcation. Why? 
You should also first initalize Serial then set pinModes into state and then put digitalWrite. It helps reading the code.</p>

<p><strong>Example:</strong></p>

<pre><code>Serial.begin(value);
pinMode(x,x);
pinMode(y,x);
pinMode(z,x);
digitalWrite(x,x);
digitalWrite(y,x);
digitalWrite(z,x);
</code></pre>

<p>More readable, isn't it?</p>

<p>Next step: Pull-up and pull-down resistors... It is not thing you need to set in your code. It is hardware connection of 1 resistor, sometimes capacitor and device. There is no use for it in your device.
Read about them here: <a href="http://www.resistorguide.com/pull-up-resistor_pull-down-resistor/" rel="nofollow noreferrer">Pull-up/pull-down</a></p>

<p>Next thing: You <strong>must not</strong> define your outputs as power pins and treat them like one. AVR's have limited power output from each pin and by doing so you can fry it very quickly.</p>

<p>If I understand your sentence correctly you need to save your angle values into variable like this (pseudo code, you have to adjust it to your case no one will write it for free):</p>

<pre><code>int xvalue, yvalue, zvalue, button;
void setup(); // all setup should go here do not skip this like me here
void loop() {
  xvalue = analogRead(xpin);
  yvalue = analogRead(ypin);
  zvalue = analogRead(zpin);
  if (button == 1) {
    if (zvalue &gt; 370)
      digitalWrite(ledPin, HIGH);
    else
      digitalWrite(ledPin, LOW);
  } else
    actionWhenPushButtonIsZero();
}
</code></pre>

<p>If you think about what I wrote and focus on your task I am sure that everything will work in your device. THINK first then ask next questions.</p>
