2

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

Code Gorilla
5,6521 gold badge17 silver badges31 bronze badges
asked Mar 7, 2017 at 10:05
3

1 Answer 1

1

Use the Timer library.

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

answered Mar 7, 2017 at 15:39
3
  • Post a code please. Commented Mar 9, 2017 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]); } Commented Mar 9, 2017 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. Commented Mar 9, 2017 at 15:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.