error: conflicting types for '...'

hey,

i got this simple code here:

int triggerdl = 2000;
int lightdl = 500;
int rotdl = 4000;
boolean red = true;
boolean yel = false;
boolean gre = false;

void setup()
{
  pinMode( 7, INPUT);
  pinMode( 8, OUTPUT);
  pinMode( 9, OUTPUT);
  pinMode(10, OUTPUT);
}

void loop(
){
    // TESTMODE - NO TRIGGERING OF THE LIGHTS

    delay(triggerdl);
    gotoRed();
    delay(rotdl);
    gotoGreen();

   // TESTMODE - NO OUTPUT

}

void gotoRed()
{
  gre = false;
  yel = true;
  delay(lightdl);
  yel = false;
  red = true;
}

void gotoGreen()
{
  yel = true;
  delay(lightdl);
  yel = false;
  red = false;
  gre = true;
}

void output()
{
  // ...
}

it should control trafficlights, but everytime i want to compile the code i get this message:

error: conflicting types for 'gotoRed'

looking forward for your solutions ... thank you, hans

Try putting the functions gotoRed(), gotoGreen() and output() above the loop() function.

This is a strange quirk about the C language: if it encounters a call to a function that hasn't been defined, it assumes that it returns an int[eger] and complains if you later define it to return void.

Moving the function is a great idea. An other way is to prototype the function. It is in concept a little like declaring a variable. This is like saying "Hey C, I will be defining a function later that is of such and such type"

In your case put void gotoRed() ; The ";" identifies it as a prototype where a { identifies it as the actual function

Some C text books say to always prototype your functions (Not that I do.) I Hope this helps Kirk

Arduino now automatically generates prototypes for your functions (well, most of the time any way, it gets confused occasionally).