Answer the question
In order to leave comments, you need to log in
Arduino. How to make a melody for two or more piezo emitters?
Good day. I want to write a simple melody for the arduino board. So to say, I am pouring into the musical sphere from the side of programming). But since any piece of music cannot exist without harmony, one piezo emitter is not enough for me. The question arises of using multiple buzzers. The "but" comes up again. The tone() operator can only play one sound source, the second buzzer just doesn't play anything. In this case, for example, only the sound with output to 3 pin, which is earlier in the code, at a frequency of 500 Hertz, will be played, the second sound to 7 pin will not be played.
tone(3,500,150);
tone(7,300,500);
delay(700);
Answer the question
In order to leave comments, you need to log in
"Only one signal can be played at a time. If the signal is already playing on one port, then calling Tone() with a different port number as a parameter will not lead to anything, if Tone() is called with the same port number, then new signal frequency."
"Generates a signal on the input/output port - a square wave, of the specified frequency and with 50% duty cycle. The duration can be set by a parameter, otherwise the signal is generated until the noTone () function is called. connected to a piezo or other speaker to play a
signal.Using the Tone() function will prevent you from using PWM on I/O ports 3 and 11 (except on the Arduino Mega board)."
To control signal generation with Arduino, you will need to learn fast PWM (pulse width modulation) signal generation. I think this article on signal generation with Arduino will be useful.
Arduino. Signal generator
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question