Hello,
I'm running arduIMU v.D and I cannot get the code to compile if I use either analogRead/Write features. I get the following:
core.a(wiring_analog.c.o):(.data.analog_reference+0x0): multiple definition of `analog_reference'
arduimu.cpp.o:(.data.analog_reference+0x0): first defined here
Something about the way arduimu works seems to break the analog features.It looks like I need to do some direct port manipulation to read analog pin 0-4 (the pins I desire to read). Does someone have some advice on an equivalent piece of code to directly replace:
analogRead(A0);
The reason for me doing this is that I am attempting to make a motion-based transmitter for multicopters, pitch and roll controlled by motion, but I would still need to poll some pots for yaw and throttle.
Thanks,
Ted
Replies
are you also running arduimu code along with that? I can do it standalone, but not while arduimu code is running. I would assume the normal SDA and SCL pins (A4 and A5) are used up, but for some reason any call to analogwrite/read results in the above. There most be something buried in the code that I do not understand.
Got it, Thanks! I went through and commented out all references to boards < 3 AND I commented out this section.
I am now able to use analogRead/Write in my code. So I decided to go back to stock code and then just comment out what I show above and NOT comment out any of the defines for < board 3 and it compiles, which I suppose is expected.
I tried just wrapping that snippet of code up like this
but when I set the board type 1 or 2 I get issues about declaring variables on compile (even without analogRead/Write in there). I suppose that is because it still compiles the "void Read_adc_raw(void)" despite not needing to.
So I have a very workable solution now considering I have board ver 3. Thank you very much Al Toma. You rock.
Hmm, I am guessing that there is a fundamental issue I am not grasping. Are the analog pins already being used to read the onboard sensors?