title: Arduino: redefinition of a function error
body: <p>"Getting the error message:</p>
  
  <blockquote>
    <p>"error: 'int ButtonStateNext' previously declared here"   (line 7 is
    where the issue lies)</p>
    
    <p>"exit status 1"</p>
    
    <p>"redefinition of 'int ButtonStateNext'</p>
  </blockquote>
  
  <p>Whenever I try to compile my arduino program..Could someone shed some light on what exactly is going wrong? I understand that the error message is telling me that i've declared ButtonNextState previously, but I see nowhere that i've done so (atleast, intentionally?). The below is the entirety of the code (posted it all since its minimal) Thanks.</p>
  
  <pre><code>String ButtonState;
  int Pin = 4;
  unsigned long timer;
  int input;
  
  //function that is to be called in loop to service
  int ButtonNextState( input ) {
  //Switch statement based on state
      switch( ButtonState )
      {       
          case Idle:
              if(input == LOW)
              {
                  //Record time
                  timer = millis();
                  //Set ButtonState to wait
                  ButtonState = "Wait";
              }
              break;
          case Wait:
              if(input == HIGH)
              {
                  ButtonState = "Idle";
              }
              else if(timer &gt;= 5)
              {
                  ButtonState = "Low";
                  return 1;
              }
              break;
          case Low:
              if(input == HIGH)
              {
                  ButtonState = "Idle";
              }
              break;
      } //end of switch statement
  
      return 0; // By default, return 0 indicating nothing is happening    
  }
  
  void setup() {
      //Set pin as input
      input = 4;
      //Set ButtonState to Idle
      ButtonState = "Idle";
  }
  
  void loop() {
      if( ButtonNextState( digitalRead( input ) ) )
      {
          //Send serial message indicating button press
          Serial.write("Button Pressed.");
      }
  }
  </code></pre>