title: How do you stop Arduino Esplora's tone function interfering with RGB LED
body: <p>On the Arduino Esplora, which is based on the Leonardo board, the PWM support of pin 5 which drives the Red component of the RGB LED looks like it shares a timer with the <code>tone</code> function.  This has the unintended consequence of rendering the Red component useless after playing a tone as its behavior becomes unpredictable.</p>
  
  <p>Here's a simple <code>setup</code> routine demonstrating the problem:</p>
  
  <pre><code>void setup()
  {
      //analogWrite(5, 255);
      //delay(1000);
      analogWrite(5, 1);
      delay(2000);
      Esplora.tone(440);
      delay(1000);
      Esplora.noTone();
  }
  </code></pre>
  
  <p>This turns on the Red channel of the LED to its lowest setting and holds it for two seconds, then plays a 440 HZ tone for 1/4 second, but as soon as the tone starts, instead of remaining on low brightness, the LED turns completely off.</p>
  
  <p>If you uncomment the first two lines, this time when the tone starts, instead of (incorrectly) turning off as before, it now (equally incorrectly) turns back to full-brightness.</p>
  
  <p>I can't figure out how to restore proper functionality of the Red component (or more specifically PWM on pin 5) after calling <code>tone</code>.</p>
  
  <p>My guess is to generate the proper HZ for the sound, <code>tone</code> changes the settings for the timer, which then affects the PWM function.  If I can find out how to manually reset the timer back to properly support PWM for the LED again, that may be the solution.  However I'm new to Arduino, timers and the like so this is pure speculation and I could be completely wrong with this approach or my understanding of it, but from what I've read, this does seem to be leading in the right direction.</p>
  
  <p>So anyone know how to restore proper PWM functionality on that pin?</p>
  
  <p>Mark</p>