View Single Post
Old Oct 08, 2012, 01:30 PM
NiVeL44 is offline
Find More Posts by NiVeL44
Registered User
Joined Mar 2007
4 Posts
Hi schumixmd and thank you

I downloaded the library, tried your code and got this:

Blink:3: error: 'TwiMaster' does not name a type
Blink.cpp: In function 'long int altimeter_update()':
Blink:15: error: 'ALTIMETER_SENSOR' was not declared in this scope
Blink:23: error: 'ALTIMETER_SENSOR' was not declared in this scope



Here is the code I tried:


#define SENSOR_ADDRESS 0xEA
#include <Wire.h>
#include <i2cmaster.h>
TwiMaster ALTIMETER_SENSOR(true);// Defining sensor object

void setup()
{
}

long altimeter_update(void){
static struct {
union {int16_t val; uint8_t raw[2]; } alt16; // 16-bit altitude from ALT-V4
} altv4;
long alt;

if(ALTIMETER_SENSOR.start(SENSOR_ADDRESS | I2C_WRITE))
{
delay(10);
ALTIMETER_SENSOR.write(0x07);
delay(10);
ALTIMETER_SENSOR.stop();
}

if(ALTIMETER_SENSOR.restart(SENSOR_ADDRESS | I2C_READ))
{
delay(10);
altv4.alt16.raw[0]=ALTIMETER_SENSOR.read(false);
delay(10);
altv4.alt16.raw[1]=ALTIMETER_SENSOR.read(true);
delay(10);
ALTIMETER_SENSOR.stop();
}

alt=altv4.alt16.val;
return alt; //return altitude in centimeters
}

void loop()
{
int altitude = altimeter_update();
}



Can you help me further?
How necessary is the additional library?
How does the code look like without it?

Yes, I'm a beginner in Arduino
NiVeL44 is offline Find More Posts by NiVeL44
Reply With Quote