Hello all, I have not seen this problem before and I could use some direction. When loading a new sketch and compiling the IDE informed me that the library I wished to use was not installed. I checked the library and it was installed. I then pulled up an older program that used the same library and it loaded and compiled fine. I re-downloaded the library and the IDE, no luck. Any help would be appreciated. Thanks, Quince
What were the libraries, or the code, and I'll see if I can reproduce the problem
Also, when you verify the script it shows which ones it's found. You could compare those that work with the ones that don't.
Here a (reformatted) sample of the output when I 'verify' one of my sketches
The -I lines show where the libraries are looked for
Detecting libraries used...
/home/mark/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++
-c
-g
-Os
-w
-std=gnu++11
-fpermissive
-fno-exceptions
-ffunction-sections
-fdata-sections
-fno-threadsafe-statics
-Wno-error=narrowing
-flto
-w
-x
c++
-E
-CC
-mmcu=atmega328p
-DF_CPU=16000000L
-DARDUINO=10607
-DARDUINO_AVR_NANO
-DARDUINO_ARCH_AVR
-I/home/mark/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino
-I/home/mark/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/eightanaloginputs
/tmp/arduino-sketch-75B0016B03FA06C15AD1462BB02B01BF/sketch/Tank_Controller_Code.ino.cpp
-o
/dev/null
This is the code that will not use the library. Thanks for the look-see. Quince
[code]
#include <Servo.h>
#include <Wire.h>
#include <QMC5883L.h> // QMC5883L library
// QMC5883L I2C address
#define QMC5883L_ADDRESS 0x0D
// Create a Servo object
Servo myservo;
// Create an instance of the QMC5883L class
QMC5883L compass;
int counter = 90;
int previousHeading = 0;
unsigned long start_time = 0;
void setup() {
// Start I2C communication
Wire.begin();
// Initialize the QMC5883L
compass.init();
// Setup Serial Monitor
Serial.begin (115200);
// Attach servo on pin 9 to the servo object
myservo.attach(9);
}
void loop() {
// Read the current heading from the QMC5883L
int currentHeading = compass.getHeading();
// Check if the current heading is different from the previous heading
if (abs(currentHeading - previousHeading) > 3) {
// Update the servo position
counter = map(currentHeading, 0, 360, 0, 180);
myservo.write(counter);
Serial.print("Position: ");
Serial.println(counter);
// Reset the start time
start_time = millis();
}
// Check if no movement is detected for 500ms
if (millis() - start_time > 500) {
// Return the servo to the initial counter
myservo.write(90);
counter = 90;
Serial.println("Returning to initial position");
}
// Update previousHeading with the current heading
previousHeading = currentHeading;
}
[/code]
@quince The message about not finding a library is board specific. For instance yesterday I was looking at a library issue and found several versions of the library, each stored within the specific boards folder structure. Also confusion over <lib.h> vs "lib.h" can lead to unexpected results.
Posting some of your code usually the first page that shows what header files are included is enough in this case. Also a screenshot of the IDE preferences, and IDE Tools menu as seen in attached picture
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
There are many variants for QMC5883.
The most popular seems to be QMC5883LCompass
However, it's include file, QMC5883LCompass.h, isn't what your using in the sketch.
Do you have a url for the download of the one you're using?
IGNORE THE ABOVE
I see you attached the original file.
You're using the Compass version, so your include should be
#include <QMC5883LCompass.h>
@quince You're using a more recent/different version of the library.
The 'compass' variable/object needs to be of type: QMC5883LCompass
and
currentDirection has become getAzimuth
I think the revised code should be
#include <Servo.h>
#include <Wire.h>
#include <QMC5883LCompass.h> // QMC5883L library
// QMC5883L I2C address
#define QMC5883L_ADDRESS 0x0D
// Create a Servo object
Servo myservo;
// Create an instance of the QMC5883L class
QMC5883LCompass compass;
int counter = 90;
int previousHeading = 0;
unsigned long start_time = 0;
void setup() {
// Start I2C communication
Wire.begin();
// Initialize the QMC5883L
compass.init();
// Setup Serial Monitor
Serial.begin (115200);
// Attach servo on pin 9 to the servo object
myservo.attach(9);
}
void loop() {
// Read the current heading from the QMC5883L
// int currentHeading = compass.currentHeading();
int currentHeading = compass.getAzimuth();
// Check if the current heading is different from the previous heading
if (abs(currentHeading - previousHeading) > 3) {
// Update the servo position
counter = map(currentHeading, 0, 360, 0, 180);
myservo.write(counter);
Serial.print("Position: ");
Serial.println(counter);
// Reset the start time
start_time = millis();
}
// Check if no movement is detected for 500ms
if (millis() - start_time > 500) {
// Return the servo to the initial counter
myservo.write(90);
counter = 90;
Serial.println("Returning to initial position");
}
// Update previousHeading with the current heading
previousHeading = currentHeading;
}
Thank you all. I will give it a try. Quince
