WWV decoder

I've seen a lot of programs to decode WWVB, but I have yet to see one for WWV. That's probably for good reason since WWVB is a much lower frequency and is far far easier to receive, but I have to do WWV for a project. 

I'm not asking for it to be done for me, I just don't have a way to test it without having the entire radio assembly ready and I just don't have it, so all I ask is if someone could eyeball my code and let me know if it looks like it will work. So, my code.

[code]#include <LiquidCrystal.h>  // initialize library
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);  // pins for LCD
int wwvbitarray[59] = {  //  59 bits because first bit is always no signal
    0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 
int wwvinput = 8;  // This is making wwvinput pin 8
unsigned long wwvpulselength;  // This is for the initial synchronizing stage
unsigned long wwvdbrlength;  // This is used for detecting logic 1s, 0s, and markers

So far this is all the integers/arrays I have assigned, the array is 59 bits for a reason I’ll explain a couple lines down.

void setup()
{
  pinMode(wwvinput, INPUT); // Same as above, wwvinput is pin 8 and an input
  lcd.begin(16, 2);  // initializing the LCD for the size I have
  lcd.print("Please wait."); // Showing something while the decoder finds the time
}
void loop()
{
wwvpulselength = pulseIn(wwvinput, HIGH);  // This is detecting the 0 second, which will be 1000 milliseconds of HIGH
if (wwvpulselength > 950)  //  pulseIn times out at 1 second by default, so 950 is what I used
{ setbits();} // When it finds the sync, it moves on to the next function to set a bit in each individual weight area

}

This is the part I’m least sure about. I don’t really know exactly how to work functions, unfortunately. My input is coming off of a LM567, which will be high when there is no signal or dB reduced signal, and low when the signal is detected. WWV has a full second of no signal every :00, so I figured once it detected that full second, I could move on with the program and start decoding.

void setbits()  //  This is the decoding function to find the logic states for each bit
{
  for (int i=1; i <= 59; i++){ //  59 bits in the array, so it will write to each one; I might be able to drop a couple and do my decoding then
    wwvdbrlength = pulseIn(wwvinput, LOW);  // this reads the lows of the dB reduced signal and checks the time against if statements
    if (wwvdbrlength < 300) // 0 is 200ms, so 300 gives some leeway
    { wwvbitarray[i] = 0;}
    else if (300 < wwvdbrlength < 600) // 1 is 500ms, so 600
    { wwvbitarray[i] = 1;}
    else if (600 < wwvdbrlength < 900) // marker is 800
    { wwvbitarray[i] = 2;}
    else if ( wwvdbrlength > 900 ) // If the pulse times out or is greater than it should be, it goes back to finding the sync
    { loop(); }
  }
}

So again, not quite sure here. What I think this will do is, as it moves through the 59 individual bits, it will set the corresponding bit to either 0, 1, or 2. 2 I have as a marker, 0 and 1 are purely logic states that correspond to the dB reduced time outputs of the LM567.

That’s all I have so far, from here I need to work on decoding and displaying to the LCD (I’m using the LiquidCrystal library that came with the compiler).

What I really need to know is: At a glance will this work(ish)? And where can I decode from here? A lot of the processor time is spent polling so I’m not 100% on whether it will work or not. Like I said I’m not asking for it to be done I’m just trying to stumble through this hopefully to actually get a valid output onto an LCD.

Thanks a lot for any input, or no input, I know this post is long winded.

Edit: I put comments in the code to make it more clear, and also changed the name of a function that was ambiguous.[/code]

Edit: I put comments in the code to make it more clear...

If your instructor doesn't require you to do this all the time then he isn't doing his job. Ideally you write the comments first, then add the code.

Don