2

I need to play sound on 10 piezos at once. How to do that without delay() function.

Code Gorilla
  • 5,617
  • 1
  • 14
  • 31
Lowder
  • 27
  • 5

1 Answers1

1

Use the Timer library.

You can attach up to 10 events to each Timer object you declare. That will suit your use case.

Enric Blanco
  • 2,103
  • 1
  • 12
  • 25
  • Post a code please. – Lowder Mar 09 '17 at 13:33
  • Why this code not work? `long ids[10]; void playNote(int pin, unsigned long freq) { int ms = 1000/freq; ids[pin] = t.oscillate(pin, ms / 2, HIGH); } void stopNote(int pin) { t.stop(ids[pin]); }` – Lowder Mar 09 '17 at 13:40
  • Post a new question with your full code and not just a snippet, You'll get much better help. I'll also participate. – Enric Blanco Mar 09 '17 at 15:58