Okay thank you. Now, the LDC is empty, the altitude is not display ...
Here the final program :
LCD :
#include <Wire.h>
#include <BMP085.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
// Define LCD Pins
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
// Initialize LiquadCrystal with pin setup
LiquidCrystal_I2C lcd(0x20,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
// Initialize BMP085
void setup() {
lcd.begin(16,2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial communication at 9600bps
}
void loop() {
lcd.clear();
lcd.setCursor(0,0);
rangeInCm();
delay(100);
}
Sensor :
#include <Wire.h>
int reading = 0;
int rangeInCm()
{
Wire.beginTransmission(112);
Wire.write(0);
Wire.write(0x51); // command sensor to measure in "inches" (0x50)
// use 0x51 for centimeters
// use 0x52 for ping microseconds
Wire.endTransmission();
delay(70);
Wire.beginTransmission(112);
Wire.write(byte(0x02));
Wire.endTransmission();
Wire.requestFrom(112, 2);
if(Wire.available() >= 2)
{
int reading = Wire.read();
reading = reading << 8;
reading |= Wire.read();
return reading;
}
else
return -1; // something went wrong
}
Can you see an error ?