title: JavaScript: How to perfectly time a function
body: <p>i hope you can help me with this.
  I´m writing on my bachelor thesis at the moment and came to a point where i don´t know how to move on. so here is my question:
  i´ve got a function in a given code that is called every 100ms. In this function i wrote another function that plays an audio record and it should be called only once in 10 seconds and i really do not know how to realize it.
  I tried it with an additional counter (see code below) but it doesn´t work like it´s supposed to..</p>
  
  <pre><code>if(fall_detected == true &amp;&amp; counter == 0)
  {
     counter++;
     var exec = require('child_process').exec;
     function puts(error, stdout, stderr) { console.log(stdout) }
     exec("aplay /home/test.wav", puts);  
  }
  </code></pre>
  
  <p>I tried it with a timeout after the exex-line but it doesn´t work..
  Do you have any ideas?</p>