背景:我有一个 IOIO,我用它来测量光电二极管的输出,这是转换成数字输出的。我需要找到信号在 1 和 0 之间变化的频率。到目前为止我所尝试的一切都挂起我的测试应用程序,有什么建议吗?
当前代码:
if(diode == 1 && 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);
}
}