Movable Bridge Traffic Lights

Right now, for an engineering project, Me and my group have been tasked with the construction of a movable bridge. We've managed to get a large portion of the sensor systems working, but I am having difficulty with the traffic lights

Right now, I'm using a pushbutton to switch between the four states (closed, opening, open, and closing)
for these states we need the following
Closed - CarLED needs to be solid, while BoatLED needs to be flashing
opening - both LED's must be flashing
open - CarLED needs to be flashing, while the BoatLED needs to be solid
Closing - Both must be flashing

The wiring is quite simple, pretty much I have an input from the pushbutton, much like the example provided in http://arduino.cc/en/tutorial/button#.UyPcEVFdUkU and http://arduino.cc/en/Tutorial/ButtonStateChange#.UyOjcVFdUkU
the LEDs are listed as outputs, being hooked up to the pins with 220 ohm resistors

Here is the code

//traffic light Simulation
const int CarLED = 12;
const int BoatLED = 13;
const int BoatSignal = 11;
int ButtonState= 0;
int LastButtonState = 0;
int Count = 0;


void setup()
{
  pinMode(CarLED, OUTPUT);
  pinMode(BoatLED, OUTPUT);
  pinMode(BoatSignal, INPUT);
}

void loop()
{
  Serial.println(Count);
  

  
  Serial.println(Count);
  
  if(Count == 0)
  {
    digitalWrite(CarLED, HIGH);
    digitalWrite(BoatLED, HIGH);
    Count = checkcount();
    delay(1000);
    Serial.println(Count);
    digitalWrite(BoatLED, LOW);
  }
  
  if(Count == 1)
  {
    digitalWrite(CarLED, HIGH);
    digitalWrite(BoatLED, HIGH);
    Count = checkcount();
    delay(1000);
    digitalWrite(BoatLED, LOW);
    digitalWrite(CarLED, LOW);
  }
  
  if(Count == 2)
  {
    digitalWrite(CarLED, HIGH);
    digitalWrite(BoatLED, HIGH);
    Count = checkcount();
    delay(1000);
    digitalWrite(CarLED, LOW);
  }
  
  if(Count == 3)
  {
    digitalWrite(CarLED, HIGH);
    digitalWrite(BoatLED, HIGH);
    Count = checkcount();
    delay(1000);
    digitalWrite(BoatLED, LOW);
    digitalWrite(CarLED, LOW);
  }
  
  if(Count == 4)
  {
    Count = 0;
  }
}

int checkcount()
{
  ButtonState = digitalRead(BoatSignal);                  //Checks the state of the right lanes entry button
  if (ButtonState != LastButtonState)                        //If the buttons state has changed (closed or open), then the if statement is triggered
  {
    if (ButtonState == HIGH)                                  //If the button is now on, then a car is added as "on the bridge"
    {
      Count++;                                            //Adds 1 to the count
      Serial.println(Count);                              //prints the count to the serial monitor
    }
  }
  LastButtonState = ButtonState;                             //replaces the old saved state with the new saved state
}

Any help would be appreciated

Also, a sidenote, but my Serial Monitor is not showing any of the serial prints of the count, which makes this really tricky for me to fix, anybody have any idea why this would be doing that?

It would be easier to read if you post your code using the "#" CODE button.
CLICK the MODIFY button.
Highlight the code.
CLICK the "#" CODE button and it will create a scroll window to scroll through the code.
Can you explain what the difficulty is that you are having ? (what happens with the code you posted ?)

You need a Serial.begin(9600); in your setup() function to see the Serial.print()s.

GREAT CATCH ! I missed that.(I've done that many times too but I always find it because that is the first place I look when something doesn't print,

the lights stay illuminated, and don't respond to button presses

You MUST get rid of the delay() statements. Nothing can happen while they execute. Look at the conecpt in the Blink Without Delay example sketch and the more extensive example I have written here Demonstration code for several things at the same time - Project Guidance - Arduino Forum

I note that you have "Count = checkcount();" in several places. That should always ring a warning bell saying the code is poorly planned. As far as possible no piece of code should be repeated - it only opens up the opportunity for error when one version is updated and the others are forgotten. In this case the statement could just as well go before the first "if" .

...R

i am still figure out about your code.
is it works if you do not write return this this function/routine checkout?

MD4N1:
i am still figure out about your code.
is it works if you do not write return this this function/routine checkout?

Sorry, I'm not sure if you are referring to my code, but in any case I don't understand your question.

...R

KimJongSkill:

 void loop()
{
  Serial.println(Count);  
  Serial.println(Count);
  
  if(Count == 0)
  {
    digitalWrite(CarLED, HIGH);
    digitalWrite(BoatLED, HIGH);
    Count = checkcount();
    delay(1000);
    Serial.println(Count);
    digitalWrite(BoatLED, LOW);

Here you set BoatLED LOW, but a few microseconds later, 
in the next iteration of loop(), you set it high again.
It does go off, but you don't see it, as it's off for such a short time.
  }

Here you set BoatLED LOW, but a few microseconds later,
in the next iteration of loop(), you set it high again.
It does go off, but you don't see it, as it's off for such a short time.