making a pressure switch with BMP180 and grove relay shield

http://www.seeedstudio.com/wiki/Grove_-_2-Coil_Latching_Relay

I am trying to modify the code to have the relay switch on at height and/or pressure and then back off at the same height.
I would like to know how to take the pressure code and insert on/off code.

Thanks in advance for all your help.

reading pressure section of code
{Serial.print(“Pressure = “);
Serial.print(bmp.readPressure());
Serial.println(” Pa”);}

switch on/off section of code
{
pinMode(LatchingRelay,OUTPUT);

digitalWrite(LatchingRelay,LOW);
delay(1000);
digitalWrite(LatchingRelay,HIGH);
delay(1000);}

BMP180_grove_relay.ino (2.28 KB)

Never mind, using if/else statements Iam able to turn on/off devices at around the 5th floor of any building. Thanks for looking.

this is code for my pressure switch.

#include <Wire.h>
#include <Adafruit_BMP085.h>

/*************************************************** 
  This is an example for the BMP085 Barometric Pressure & Temp Sensor

  Designed specifically to work with the Adafruit BMP085 Breakout 
  ----> https://www.adafruit.com/products/391

  These displays use I2C to communicate, 2 pins are required to  
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/

// Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)
// Connect GND to Ground
// Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5
// Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4
// EOC is not used, it signifies an end of conversion
// XCLR is a reset pin, also not used here

Adafruit_BMP085 bmp;
  #define LatchingRelay 3




void setup() {
  Serial.begin(9600);
  if (!bmp.begin()) {
	Serial.println("Could not find a valid BMP085 sensor, check wiring!");
	while (1) {}
  }
  pinMode(LatchingRelay,OUTPUT);

digitalWrite(LatchingRelay,LOW);
delay(1000);
digitalWrite(LatchingRelay,HIGH);
delay(1000);
}
  
void loop() {
  pinMode(LatchingRelay,OUTPUT);
    Serial.print("Temperature = ");
    Serial.print(bmp.readTemperature());
    Serial.println(" *C");
    
    Serial.print("Pressure = ");
    Serial.print(bmp.readPressure());
    if(bmp.readPressure()<100800)
    {
      digitalWrite(LatchingRelay,HIGH);
    }
    if (bmp.readPressure()>100800)
    {
      digitalWrite(LatchingRelay,LOW);
    }
    Serial.println(" Pa");
    
    // Calculate altitude assuming 'standard' barometric
    // pressure of 1013.25 millibar = 101325 Pascal
    Serial.print("Altitude = ");
    Serial.print(bmp.readAltitude());
    Serial.println(" meters");

    Serial.print("Pressure at sealevel (calculated) = ");
    Serial.print(bmp.readSealevelPressure());
    Serial.println(" Pa");

  // you can get a more precise measurement of altitude
  // if you know the current sea level pressure which will
  // vary with weather and such. If it is 1015 millibars
  // that is equal to 101500 Pascals.
    Serial.print("Real altitude = ");
    Serial.print(bmp.readAltitude(100600));
    Serial.println(" meters");
    
    Serial.println();
    delay(5000);
}

IMG_0498.JPG