title: Arduino - Tone without delay
body: <p>I'm trying to play a tone while changing something on an LCD display. I've searched around and tried protothreads, but it seems that the delay still blocks the program. I've also tried removing the delay altogether, but it skipped everything except the last note. Is there a way to play a tone without using delay? (millis perhaps?)</p>
  
  <p>Sample tone sequence:</p>
  
  <pre><code>//Beats per Minute
  #define BPM 250
  
  //Constants, try not to touch, touch anyways.
  #define Q 60000/BPM   //Quarter note
  #define W 4*Q         //Whole note
  #define H 2*Q         //Half note
  #define E Q/2         //Eigth note
  #define S Q/4         //Sixteenth note
  
  void toneFunction()
  {
        tone(tonePin,C5,Q);
        delay(1+W);
        tone(tonePin,C5,Q);
        delay(1+W);
        tone(tonePin,C5,Q);
        delay(1+W);
        tone(tonePin,C6,W);
  }
  </code></pre>