Hello,
I am a beginner in programming Arduino. I have an Arduino Pro Mini 328 that I want to use to read RC receiver channel signals using PinChangeInt to convert the signal to a useful value. I have a couple of simple projects finished using Arduino.
I have searched throw the forum and google to find why do I have the error but couldn't find an asnwer, each thread I've found looked specific.
I want to create a class to ease the use of the PCintPort::attachInterrupt function and the handler that is called by the interrupt.
My guess is that I do not have actually a problem with my code, but rather the way I include the header files. I have removed everything in the files to ease debugging.
The library is declared in Libraries directory and was added using Schetch->ImportLibrary ..
Could anyone support me to figure out how to solve this error?
RCRead::RCRead(int16_t inputPin)
{
pinMode(inputPin, INPUT); // set pin to input
digitalWrite(inputPin, HIGH); //use the internal pullup resistor
// attach a PinChange Interrupt to our pin on the rising edge
PCintPort::attachInterrupt(2, &InputHandle,CHANGE);
}
Hi,
Thanks for the quick feedback.
This is how I declared the headers in the sketch: #include <RCRead.h> #include <PinChangeInt.h>
If I declare PinChangeInt.h in the sketch in raises me the error:
<<
sketch_jan16a.cpp.o: In function PCintPort::PCint()': C:\Users\Cristian_Sandor\Documents\Arduino\libraries\PinChangeInt/PinChangeInt.h:456: multiple definition of PCintPort::PCint()'
RCRead.cpp.o:C:\Users\Cristian_Sandor\Documents\Arduino\libraries\PinChangeInt/PinChangeInt.h:456: first defined here
This error is shown for a lot of objects declared in PinChangeInt.h. I am like I go around a circle ... uuufff
As I said is quit obvious that I do not declare the header file correctly or in the correct order ...
And now you know why libraries are usually split between a .h file and a .cpp file. That library has everything stuffed in the header file, so you would need to split it properly to be able to use it. Dumb design, in my opinion.
Agree that the design it may be not really the best, but still there are just a couple of line codes and not able to rid of this errors since about 3 hours ...
Agree that the design it may be not really the best, but still there are just a couple of line codes and not able to rid of this errors since about 3 hours ...
The only way to resolve the issue is to split the library into a header file and a source file. It isn't clear that you have done that.
If you have, you need to post your header file and your source file and your sketch, so we can replicate the problem.
I will have to dig it more deep.
I've write the code in a sketch and seems to work well. I'll finish the code, I'll make it run properly and then I'll create the library files (H, CPP).
Hi dacair,
I'm working on a different library using the same PinChangeInt. I had the same error, and solved it by putting the PinChangeInt.h file in the same directory as my FlowCounters library. This, however, will not be optimal when a user of the FlowCounters library expects the PinChangeInt library to be in its own folder.