Library Wire.h

Hello to all.
I want to create a new library with Wire.h header.
But when I compile, I have an error the same as below.
Thanks.

//I2CH.h
#ifndef I2CH_H
#define I2CH_H
#include "Arduino.h"
#include "Wire.h"
class I2CH
{
		public:
   			void I2CBegin();		
};
//I2CH.cpp
#include "I2CH.h"
void I2CH::I2CBegin()
{
		Wire.begin(); 	// join i2c bus (address optional for master)
}
//Main.ino
#include <I2CH.h>
#include <Wire.h>

I2CH I2C;

void setup() {
I2C.I2CBegin();
}

void loop() {
}

//Compile error
C:\Users\Leon\AppData\Local\Temp\build6400254520694862223.tmp\aa.cpp.o: In function setup': C:\Program Files (x86)\Arduino/aa.ino:7: undefined reference to I2CH::I2CBegin()'
collect2.exe: error: ld returned 1 exit status. Error compiling.

I copied and pasted your code into the Arduino IDE (1.0.5). I had to add a #endif statement to the .h file, and had to change the #include statement in the sketch, that includes the I2CH.h file, to use "" instead of <>. When I did that, I got one error:

Binary sketch size: 2,616 bytes (of a 258,048 byte maximum)

Using the class name in the method name is not standard practice. The method should be called begin().

now I've changed the name of method but still has that error.
What should I do now?

What should I do now?

Open a couple more threads?

I do not know what is wrong with your system. Your code compiles, links, and does nothing on my system.

Do not start any more threads!

Thank you all of you guys.
Finally I've got solved problem.
Problem was extension of cpp file . It is I2CH.cpp .but I'd written I2CH.Cpp

Hello again.
I have another problem in creating my header.
When I want to compile this error apears:

//I2CH.h

#ifndef I2CH_H
#define I2CH_H
#include <Arduino.h>
#include <Wire.h>
class I2CH
{
 public:
        void aaa();
        void receiveEvent(int howMany);
}
#endif
//I2CH.cpp
#include "I2CH.h"

void I2CH::aaa()
{
    Wire.onReceive(receiveEvent);
}

void I2CH::receiveEvent(int howMany)
{
    while( Wire.available()>0) // loop through all but the last
  {
    char c = Wire.read(); // receive byte as a character
  }
}
//main.ino   

#include <I2CH.h>
#include <Wire.h>
I2CH i2c;

void setup()
{
      Wire.begin(4);
      i2c.aaa();
}

error:
Wire.h:67:10: note: void TwoWire::onReceive(void ()(int))
no known conversion for argument 1 from '' to 'void (
)(int)'
Error compiling.

Nobody can help?

leoncorleone:
Nobody can help?

Maybe the experts are in bed. Have patience.

Why have you another Thread that seems to be about the same project ?

...R

Nobody can help?

Yes, if you give us time.

void I2CH::aaa()
{
    Wire.onReceive(receiveEvent);
}

When the Wire class receives some data, you want it to call the receiveEvent() function. For which instance of the class?

Suppose that you have

I2CH one;
I2CH two;
I2CH three;

and some data comes on on the I2C pins. Which instance should deal with the data?

It does not matter AT ALL that you only plan to have one instance of the class. The compiler can not know what your plans are.

The receiveEvent() method must be static (a class function, rather than a member function) in order to be used that way.

Of course, that will cause a bunch of other problems, because the static method belongs to the class, not an instance of the class. It will have the same problem knowing which instance of the class gets the data.