error: conflicting types for '[methodName]'

I am writing software to read and determine peak values from a memsic 2125 accelerometer. In my code I have a convenience method to update sensor reading values, 'void readNew()'. It is the only method by this name.

When I try to compile the program, it refuses and gives me the error:
" error: conflicting types for 'readNew' "

Can anyone tell me why I'm getting this error?

Pasted below is the source code. The troublesome method is at the end of the code. I am using Arduino 0003 on an Apple iBook G4 with OS X Tiger.

EDIT: I removed the method type (void) from both readNew() and saveOld() methods. The source code now compiles fine. If I uncomment the last part of the source code though (the two printout methods), I get an "unexpected token: void" error for the last method. This all sounds like some syntax error earlier in the code, but I can't find anything wrong with it.

/* _________________________________________
Reading peak values from an accelerometer


*/

// Hardware
int ledPin = 13;
int xaccPin = 7;
int yaccPin = 6;

// low-level
int count, value;

// Constants
//#define MOTION_THRESHOLD 100; // gives strange errors.
int MOTION_THRESHOLD = 100;

// Variables
int nx, ox; // new and old x acceleration values

// method to determine if motion above threshold is detected
boolean motionStarted() {
boolean hasStarted;
readNew(); // read new acc. values
hasStarted = (nx - ox) > MOTION_THRESHOLD; // TODO: implement y axis
saveOld(); // save old acc. values
return hasStarted;
}

void loop() {
// wait until action detected
while(!motionStarted());

// loop until acceleration has ceased
while(nx > ox) {
saveOld();
readNew();
printInteger(nx);
printNewline();
delay(50); // ONLY FOR DEBUG
}

printString("turned.");
printNewline();
}

/* -------------------------------------------------
Low-level stuff

*/

void setup() {
beginSerial(19200); // Sets the baud rate to 19200
pinMode(ledPin, OUTPUT);
pinMode(xaccPin, INPUT);
pinMode(yaccPin, INPUT);
// initialize new and old acc. values
readNew();
saveOld();
}

// method to convert raw acc. value to acceleration
int operateAcceleration(int time1) {
return abs(8 * (time1 / 10 - 500));
}

// method to read value from accelerometer sensor
int readAcc(int axe) {
count = 0;
value = digitalRead(axe);
while(value == HIGH) { // Loop until pin reads a low
value = digitalRead(axe);
}
while(value == LOW) { // Loop until pin reads a high
value = digitalRead(axe);
}
while(value == HIGH) { // Loop until pin reads a low and count
value = digitalRead(axe);
count = count + 1;
}
//determine the value
return operateAcceleration(count * 18); // * 18 calculates the time in miliseconds
}

// method to update acceleration values
void readNew() {
nx = readAcc(xaccPin);
//ny = readAcc(yaccPin);
}

// method to save old acceleration values
void saveOld() {
ox = nx;
//oy = ny;
}

/* NOT IN USE:
// method to print an integer to serial port
void printValue(int i) {
printInteger(i);
printNewline();
}

// method to print a string to serial port
void printValue(String s) {

}
*/

It seems that all the problems were there because the Arduino compiler needs a method to be declared at a point in the code before it is used. I thought that it compiled Java-style and not procedurally. :cry:

Arduino 0004 takes care of some of these problems for you (though you'll need to give a return type, e.g. "void" for each function). Although the C/C++ compiler used internally by Arduino requires functions to be declared before use, Arduino 0004 attempts to automatically insert these declarations for you.