Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Hi,
I'm a newbie, so hopefully some great guru out there will see the obvious answer to this. If I uncomment the pc.printf(...) line in the do{} loop below, the led lights up. If I don't, it remains dark. This is true for any value of epsilon, not just 1.0e-9. Some buffer gets flushed or something? Help?
Thanks.
JAG
#include "mbed.h" Serial pc(USBTX, USBRX); // tx, rx PwmOut led(LED1); int main() { pc.printf("\r\nVisual Acuity Tester.\r\n"); pc.printf("Press any key to begin.\r\n"); char c = pc.getc(); led = 1.0; float dutyCycle = .5; float period = 1.0e-2; float epsilon = 1.0e-9; led.period(period); led.write(dutyCycle); do{ period += epsilon; led.period(period); //pc.printf("The period is %f\r\n",period); }while(!pc.readable()); led = 0; float frequency = 1/period; pc.printf("Frequency at which you detected flicker: %fHz.\n",frequency); }