Error when verifying own code + Mirumod rx2atp code

Hi all, i encountered this error code from the picture below when i verify my code for ultrasonic sensor & Mirumod rx2atp(for Ar.Drone) and is unsure how to solve it. Any helpful comments will be appreciated! :slight_smile:

Thanks!

My guess would be, that you have screwed up your #include somehow in your sketch.

Or you have somehow corrupted the IDE installation on your computer.

tnebm93:
Hi all, i encountered this error code from the picture below when i verify my code ...

What code would that be?

Please use code tags.

Read this before posting a programming question

How to use this forum

@michinyon I'll try to reinstall if that's the case..

@Nick Gammon Sorry about that :stuck_out_tongue: The code exceeded the limitation of message i could post..I can only link you to the website to download the code >_<
(RC Groups - View Single Post - AR drone control with RC transmitter, yet another Wifi-less mod)

I would check the #include carefully, before you try re-installing anything. I would also look at the FIRST error message generated, that usually shows where the error is. Many people get dozens of error messages, and want to solve the last one first - probably because it didn't scroll off the screen. The first error message, is usually the cause of the problem.

I really don't get it with people who want to re-install stuff all the time,

tnebm93:
@Nick Gammon Sorry about that :stuck_out_tongue: The code exceeded the limitation of message i could post..I can only link you to the website to download the code >_<

Yes, well as the link explains you can attach code as an attachment, eg. a .zip file.

Looking at the r2xatp source, it appears to be designed to be built and loaded on the Arduino without the Arduino core. For example, it contains its own definition of function main(). Maybe this worked when using Arduino 0022/0023 (which is what the web page says it has been tested with), but not with Arduino 1.0 and later.

@michinyon i think the include doesn't seemed to be the source of the error though..

@Nick Gammon Ahh i was wondering where's the attach file button..should've clicked the Additional Options :blush: Thanks though! :slight_smile:

@dc42 I guess i missed out that part "when using Arduino 0022/0023 (which is what the web page says it has been tested with), but not with Arduino 1.0 and later" my bad..thanks for pointing that out though! :slight_smile:

Well..I've tried using the old versions of Arduino 0022 & 0023 but still get the same error message..It seemed like there's duplicate of files in my sketch & the libraries but i can't find any duplication at all when i navigate to the libraries =( P.S the error message pops out only when i verify it with my modified code below..

//Feel free to use this code.
//Please be respectful by acknowledging the author in the code if you use or modify it.
//Author: Bruce Allen
//Date: 23/07/09

//Analog pin 1 for reading in the analog voltage from the MaxSonar device.
//This variable is a constant because the pin will not change throughout execution of this code.
const int anPin0 = 0;
const int anPin = 1;

//variables needed to store values
long anVolt0, anVolt, inches0, inches, cm0, cm, dist0, dist;
int sum=0;//Create sum variable so it can be averaged
int sum0 = 0;//Create sum variable so it can be averaged
int avgrange=60;//Quantity of values to average (sample size)

void setup() {
  //This opens up a serial connection to shoot the results back to the PC console
  Serial.begin(9600);
}
void loop() {
  //MaxSonar Analog reads are known to be very sensitive. See the Arduino forum for more information.
  //A simple fix is to average out a sample of n readings to get a more consistant reading.\\ 
  //Even with averaging I still find it to be less accurate than the pw method.\\ 
  //This loop gets 60 reads and averages them

  for(int i = 0; i < avgrange ; i++) //pin A0
  {
    //Used to read in the analog voltage output that is being sent by the MaxSonar device.
    //Scale factor is (Vcc/512) per inch. A 5V supply yields ~9.8mV/in
    //Arduino analog pin goes from 0 to 1024, so the value has to be divided by 2 to get the actual inches
    anVolt0 = analogRead(anPin0)/2;
    sum0 += anVolt0;
    delay(10);
  }
  
  for(int i = 0; i < avgrange ; i++) //pin A1
  {
    //Used to read in the analog voltage output that is being sent by the MaxSonar device.
    //Scale factor is (Vcc/512) per inch. A 5V supply yields ~9.8mV/in
    //Arduino analog pin goes from 0 to 1024, so the value has to be divided by 2 to get the actual inches
    anVolt = analogRead(anPin)/2;
    sum += anVolt;
    delay(10);
  }  
  
  inches0 = sum0/avgrange; //pin A0
  cm0 = inches0 * 2.54; //pin A0
  dist0 = cm0 * cos(0.785); //pin A0
  inches = sum/avgrange; //pin A1
  cm = inches * 2.54; //pin A1
  dist = cm * cos(0.785); //pin A1
//  Serial.print(inches);
//  Serial.print("in, ");
  Serial.print(cm0);
  Serial.print("cm(A0), ");
  Serial.print(dist0);
  Serial.print("cm(A0dist),  ");
  Serial.print(cm);
  Serial.print("cm(A1), ");
  Serial.print(dist);
  Serial.print("cm(A1dist)");
  Serial.println();
  //reset sample total
  sum = 0;
  sum0 = 0;
  delay(500);
}

Using IDE 1.0.5 that code in the previous post compiles without errors for me (for a Uno).

@Nick Gammon Sorry, i rephrase my sentence..I got that list of errors when i verify my code alongside with the mirumod rx2atp code..just alone my code, the rx2atp has no problem with arduino uno too :slight_smile: I've attached my code below >_<

sketch_nov04a.zip (42.6 KB)

core.a(wiring.c.o): In function `init':
/Applications/Arduino_1.0.5.app/Contents/Resources/Java/hardware/arduino/cores/arduino/wiring.c:193: multiple definition of `init'
rx2atp.c.o:rx2atp.c:2860: first defined here
void init(void)

Well, init is defined twice. There is an init in wiring.c and you have your own one.

int main(void)
{
	u08_t	i, j, k;

AGAIN:
	init();

#if	U4 == 0
	/* Nano, ProMini - RC receiver hardware bits on port D[7:2] */
#if	RX_CON == 0
	gl.rxs.chn[S_THRO].msk = _BV(7);

You have your own main as well. You can't have two mains.

I'm not sure what you are trying to do. You can't bang two lots of code together in two different files and hope for the best.


		goto AGAIN;

Ach! Better look up how to do loops in C.

@Nick Gammon thanks for the quick reply! FYI, the codes that you've pointed out are from Mirumod, my code is the sketch_nov04a :slight_smile: I'm trying to interface this 2 codes together with the Ar.Drone for my school project :wink:

FYI, the codes that you've pointed out are from Mirumod, my code is the sketch_nov04a. I'm trying to interface this 2 codes together with the Ar.Drone for my school project

So? Duplicate is still duplicate. It doesn't matter which one you claim is the original.

@PaulS Well, thanks for pointing out again :expressionless:

Any solutions to the error code below? I've tried char foo; & #include <SoftwareSerial.h> but both doesn't seemed to be the solution :~

3.png

Does the file have #include "Arduino.h" at the start?

@dc42 nope, the error still exist even when i add that line in.. :disappointed_relieved:

Perhaps you need to rename the .c file to .cpp.

@PaulS i think it solved the problem after renaming but any idea how is this code for (c = gl.rxs.chn + NEL(gl.rxs.chn); --c >= gl.rxs.chn; mch >>= 1) related to the error below? :confused: