Pages: [1]   Go Down
Author Topic: Problema con librería libcompass  (Read 1003 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hola, acabo de descargarme la librería libcompass para la brújula hmc6352 y al compilar el código de ejemplo me salta este error:


\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp: In constructor 'LibCompass::LibCompass(uint8_t)':
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:54: error: 'OUTPUT' was not declared in this scope
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:54: error: 'pinMode' was not declared in this scope
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:55: error: 'LOW' was not declared in this scope
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:55: error: 'digitalWrite' was not declared in this scope
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:57: error: 'HIGH' was not declared in this scope
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp: In member function 'float LibCompass::GetHeading()':
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:80: error: 'class TwoWire' has no member named 'send'
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:82: error: 'delay' was not declared in this scope
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:84: error: 'millis' was not declared in this scope
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:87: error: 'class TwoWire' has no member named 'receive'
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp: In member function 'bool LibCompass::Calibrate()':
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:133: error: 'delay' was not declared in this scope
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:141: error: 'class TwoWire' has no member named 'send'
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:144: error: 'delay' was not declared in this scope
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:160: error: 'class TwoWire' has no member named 'send'
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp: In member function 'void LibCompass::Sleep()':
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:176: error: 'class TwoWire' has no member named 'send'
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp: In member function 'void LibCompass::Wake()':
\Downloads\arduino-1.0.1\libraries\LibCompas\LibCompass.cpp:186: error: 'class TwoWire' has no member named 'send'


Alguien me puede decir a que se debe, gracias.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hola,
pudiste solucionar ese problema?. Yo acabo de probar la librería y me sale lo mismo, falta incluir alguna librería?

Te agradecería me ayudaras si es que has podido solucionar el problema, si doy con la solución la posteo.

Saludos,
Akuthor
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Fui capaz de que funcionara la verdad es que ahora mismo no me acuerdo que era lo que le pasaba. Mañana te paso el código, que ahora no lo tengo, que usé yo y a ver si así te funciona.
Saludos.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hola, prueba con estos dos códigos.

Código 1:
Code:
#include <Wire.h>
int HMC6352Address = 0x42;
// This is calculated in the setup() function
int slaveAddress;
int ledPin = 13;
boolean ledState = false;
byte headingData[2];
int i, headingValue;
void setup()
{
// Shift the device's documented slave address (0x42) 1 bit right
// This compensates for how the TWI library only wants the
// 7 most significant bits (with the high bit padded with 0)
slaveAddress = HMC6352Address >> 1;   // This results in 0x21 as the address to pass to TWI
Serial.begin(9600);
pinMode(ledPin, OUTPUT);      // Set the LED pin as output
Wire.begin();
}
void loop()
{
  // Flash the LED on pin 13 just to show that something is happening
  // Also serves as an indication that we're not "stuck" waiting for TWI data
  ledState = !ledState;
  if (ledState) {
    digitalWrite(ledPin,HIGH);
  }
  else
  {
    digitalWrite(ledPin,LOW);
  }
  // Send a "A" command to the HMC6352
  // This requests the current heading data
  Wire.beginTransmission(slaveAddress);
  Wire.write("A");              // The "Get Data" command
  Wire.endTransmission();
  delay(10);                   // The HMC6352 needs at least a 70us (microsecond) delay
  // after this command.  Using 10ms just makes it safe
  // Read the 2 heading bytes, MSB first
  // The resulting 16bit word is the compass heading in 10th's of a degree
  // For example: a heading of 1345 would be 134.5 degrees
  Wire.requestFrom(slaveAddress, 2);        // Request the 2 byte heading (MSB comes first)
  i = 0;
  while(Wire.available() && i < 2)
  {
    headingData[i] = Wire.read();
    i++;
  }
  headingValue = headingData[0]*256 + headingData[1];  // Put the MSB and LSB together
  Serial.print("Current heading: ");
  Serial.print(int (headingValue / 10));     // The whole number part of the heading
  Serial.print(".");
  Serial.print(int (headingValue % 10));     // The fractional part of the heading
  Serial.println(" degrees");
  delay(500);
}



Código 2:
Code:
byte val = 0;
  byte data[2];
  int  j, frac;

 
void setup()  { 
  Serial.begin(9600);
  delay(100);
  Wire.begin();
 
  Serial.print("RST\r\n");
  delay(100); 
}


void loop()
{
 
  Wire.beginTransmission(byte(0x21));
  Wire.write(0x41); //A
  Wire.endTransmission();
  delay(8); //6000 microseconds minimum 6 ms

  Wire.requestFrom(0x21, 2);
  j = 0;
  while(Wire.available())
  {
    char c = Wire.read();
    data[j] = c;
    j++;
  }
  frac = data[0]*256 + data[1];
 
  Serial.println( (frac/10.0));
  delay(1000);
 
}
Logged

Pages: [1]   Go Up
Jump to: