Frequency from binary input
<p>Background: I have a IOIO which I am using to measure the output from an photodiode, this is the converted into a digital output. I need to find the frequency at which the signal changes between 1 and 0. Everything I have tryed so far has hanged my test app, any suggestions?</p>

<p>current code:</p>

<pre><code>if(diode == 1 &amp;&amp; frequencyFound == false){
  startTime = System.currentTimeMillis();
  while((frequencyFound == false)){
     if(diode == 0){
        while(frequencyFound == false){
            if(diode == 1){
                double endTime = System.currentTimeMillis();
                time = endTime - startTime;
                frequency = (long) (1.0 / time);
                frequencyFound = true;
            }
            Thread.sleep(100);
        }
     }
     Thread.sleep(100);
  }
}
</code></pre>
