Hello everybody. I am making a where I'll have basic functions to read and write through I2C.
Then if I include the library Wire I get this error.
/I2C.h:4: fatal error: Wire.h: No such file or directory
The library look like that
I2C.H
#ifndef I2C_H_
#define I2C_H_
#include "Arduino.h"
#include <Wire.h>
#define ADDRESS 0x21 // Define address of OV7670
#define REGISTERS 0x91 // Define # of Registesr on OV7076
class I2CClass {
public:
I2CClass();
void init();
void write(uint8_t slave_address, uint8_t data);
void read_bank();
private:
uint8_t initialized;
};
extern I2CClass I2C;
#endif
I2C.CCP
#include "I2C.h"
I2CClass::I2CClass(){
initialized = false;
}
void I2CClass::init(){
if (!initialized) {
Wire.begin();
initialized = true;
}
}
void I2CClass::write(uint8_t slave_address, uint8_t data){
delay(5);
Wire.beginTransmission(ADDRESS); // Start transmission to device
Wire.write(slave_address); // Send register address
Wire.write(data); // Send value to write
Wire.endTransmission(); // End transmission
delay(5);
}
void I2CClass::read_bank(){
int count = 0;
byte tmp;
while(count<REGISTERS)
{
byte highByte=0;
Serial.print("\n Registro num: ");
Serial.println(count,HEX);
Wire.beginTransmission(ADDRESS); //Start communication with cmps03
Wire.write(count); //Send the register we wish to read
Wire.endTransmission();
Wire.requestFrom(ADDRESS, 1); //Request high byte
while(Wire.available() < 1); //While there is a byte to receive
highByte = Wire.read(); //Read the byte as an integer
Serial.println(highByte,HEX);
delay(25);
count++;
}
}
I2CClass I2C;
How can I solve it? If have tried to copy wire.h and wire.ccp to the scketh folder but them also ask for twy.h and more libraries..
Thanks in advance