Wire.h won't compile


while trying compile following program sketch run digital compass (hmc5983, gy-282) i  errors follows;

program code listing

code: [select]

/*
an arduino code example for interfacing with the hmc5883

by: jordan mcconnell
 sparkfun electronics
 created on: 6/30/11
 license: oshw 1.0, http://freedomdefined.org/oshw

analog input 4 i2c sda
analog input 5 i2c scl
*/

#include <wire.h> //i2c arduino library

#define address 0x1e //0011110b, i2c 7bit address of hmc5883

void setup(){
  //initialize serial , i2c communications
  serial.begin(9600);
  wire.begin();
  
  //put hmc5883 ic correct operating mode
  wire.begintransmission(address); //open communication hmc5883
  wire.send(0x02); //select mode register
  wire.send(0x00); //continuous measurement mode
  wire.endtransmission();
}

void loop(){
  
  int x,y,z; //triple axis data

  //tell hmc5883 begin reading data
  wire.begintransmission(address);
  wire.send(0x03); //select register 3, x msb register
  wire.endtransmission();
  
 
 //read data each axis, 2 registers per axis
  wire.requestfrom(address, 6);
  if(6<=wire.available()){
    x = wire.receive()<<8; //x msb
    x |= wire.receive(); //x lsb
    z = wire.receive()<<8; //z msb
    z |= wire.receive(); //z lsb
    y = wire.receive()<<8; //y msb
    y |= wire.receive(); //y lsb
  }
  
  //print out values of each axis
  serial.print("x: ");
  serial.print(x);
  serial.print("  y: ");
  serial.print(y);
  serial.print("  z: ");
  serial.println(z);
  
  delay(200);
}



error messages listing

compasstest1.ino: in function 'void setup()':
compasstest1.ino:24:8: error: 'class twowire' has no member named 'send'
compasstest1.ino:25:8: error: 'class twowire' has no member named 'send'
compasstest1.ino: in function 'void loop()':
compasstest1.ino:35:8: error: 'class twowire' has no member named 'send'
compasstest1.ino:42:14: error: 'class twowire' has no member named 'receive'
compasstest1.ino:43:15: error: 'class twowire' has no member named 'receive'
compasstest1.ino:44:14: error: 'class twowire' has no member named 'receive'
compasstest1.ino:45:15: error: 'class twowire' has no member named 'receive'
compasstest1.ino:46:14: error: 'class twowire' has no member named 'receive'
compasstest1.ino:47:15: error: 'class twowire' has no member named 'receive'
error compiling.

clearly wire.h file not finding twowire.send , twowire.receive class because has not been declared.
i notice jordan mcconnell has updated wire.cpp file can not find updated wire.h file.
can soneone please point me updated (and companion) wire.h file.

thanking in advance assistance here.

thanking in advance assistance here.
you got code computer museum?

either downgrade arduino ide version number less 1.0.

or replace wire.receive(); wire.read(); , wire.send(xxx); wire.write(xxx);


Arduino Forum > Using Arduino > Programming Questions > Wire.h won't compile


arduino

Comments