1

I found a library called Timer. I want to use timers for pieso. My code is:

long ids[10];
void playNote(int pin, unsigned long freq) {
  float ms = 1000/freq;
  ids[pin] = t.oscillate(pin, ms, LOW);
}

void stopNote(int pin) {
  t.stop(ids[pin]);
}

Here is a full code. Where is a problem? Sorry for my bad English.

  • Why not just use the tone() function? – Majenko Mar 10 '17 at 11:50
  • @Majenko because i need to beep with many piezo – Lowder Mar 10 '17 at 11:51
  • How many? You can only do one per timer, unless you want to do fractions of a base frequency, and that gets overly complex. What are you actually trying to achieve here? – Majenko Mar 10 '17 at 11:51
  • @Majenko 10 But with that library i can do many actions. About 10 – Lowder Mar 10 '17 at 11:55
  • You can't oscillate multiple pins at multiple frequencies from a single timer. – Majenko Mar 10 '17 at 12:49