Hallo,
Ich möchte den Sensor GP2Y0A21YK0F von Sharp anwenden und habe dazu zunächst einen kleinen Sketch ausprobiert.
/******************************************************************
Created with PROGRAMINO IDE for Arduino - 09.03.2021 10:55:26
Project : Test Sharp IR Sensor
Libraries :
Author : Benne de Bakker
Description :
******************************************************************/
/*SHARP GP2Y0A21YK0F IR distance sensor with Arduino and SharpIR library example code. More info: https://www.makerguides.com */
// Include the library:
#include <SharpIR.h>
// Define input pin:
#define IRPin A0
// Create variable to store the distance:
int distance_cm;
// Create a new instance of the SharpIR class:
SharpIR mySensor(SharpIR::GP2Y0A21YK0F,IRPin );
//SharpIR mySensor(model,IRPin);
void setup() {
// Begin serial communication at a baudrate of 9600:
Serial.begin(9600);
}
void loop() {
// Get a distance measurement and store it as distance_cm:
distance_cm = mySensor.getDistance(false);
// Print the measured distance to the serial monitor:
Serial.print("Mean distance: ");
Serial.print(distance_cm);
Serial.println(" cm");
delay(1000);
}
Ich bekomme jedoch folgende Fehlermeldung, zu der ich keine Lösung finde:
libraries\SharpIR\SharpIR.cpp.o (symbol from plugin): In function SharpIR::getDistance(bool)': (.text+0x0): multiple definition of
SharpIR::getDistance(bool)'
sketch\SharpIR.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Fehler beim Kompilieren für das Board Arduino Uno.
Die einfache Schaltung ist als Anlage beigefügt.