I had my sketch and it worked, now I separate in my own Library and it stop working ![]()
What's wrong??? I'm forgetting somethin??
#include <Wire.h>
#include "Compas.h"
Compas com;
void setup()
{
}
/////////////////////////////////////////////
////////////////////////////////////
void loop() {
com.Escribir();
}
#ifndef Compas_h
#define Compas_h
#include <Wire.h>
#include "WProgram.h"
class Compas {
public:
Compas();
void Escribir();
private:
void Orientacion();
int HMC6352Direccion;
int HMC6352;
int ContBrujula;
int grados;
byte entradagrados[2];
};
#endif
#include "Compas.h"
Compas::Compas()
{
HMC6352 = HMC6352Direccion >> 1;
Wire.begin();
}
void Compas::Orientacion()
{
ContBrujula = 0;
Wire.beginTransmission(HMC6352);
Wire.send("A");
Wire.endTransmission();
delay(10);
Wire.requestFrom(HMC6352,2);
while(Wire.available() && ContBrujula < 2)
{
entradagrados[ContBrujula] = Wire.receive();
ContBrujula++;
}
grados = int((entradagrados[0]*256)/10);
}
void Compas::Escribir()
{
Orientacion();
if(grados>=100){
Serial.print(grados);
}else if(grados>=10 && grados<100){
Serial.print("0");
Serial.print(grados);
}else if(grados<10){
Serial.print("00");
Serial.print(grados);
}
}