![]() The same problem would occur with toneAC library. I did look at the "Tutorial: multiple tones", but it doesn't allow me to play multiple tones at the same time. What I want to achieve is having 5 piezo elements playing simultaneously, with the ability to change the volume of each piezo element individualy with some lines of code. Sorry if I'm not clear enough, I'm trying to provide as much information as possible, but I guess it's more confusing than helping ![]() Sorry if it sounds confusing, I'm having a hard time explaining, as english is not my primary language That way I could connect the piezo element with different resistors values, and use the IC to select which resistor the tone will go through. Maybe what I'm really looking for, is some kind of IC that will receive one input, and have multiple output (but only one active at once). Maybe the title of the topic isn't relevant enough, but I was looking for either the answer to my question about the tone library, or any other possible way to achieve what I really want to do : control the volume of my piezo elements in a way or another. Since the only remaining timer is timer 0, my sketch doesn't work anymore because it screws the delay() function, which is crucial for the application. Instead of re-using the timer 2, it looks for another available timer. ![]() When I try to change the output pin of one player by calling, for example : tonePlayer.begin(10) This code eats 5 timers on my arduino mega. So I start by initializing my 5 piezo elements like this : Tone tonePlayer My question was more related to the tone library itself.Įverytime I want to initialize a pin as an output, it "eats" an internal timer of the arduino. I know the schema only shows one piezo element, but my real circuit is more complex and has 5 of them connected on my arduino. That's why I had to use the tone library I linked above, it allows me to use tone on more than one pin at the same time. I'm aware of the built-in tone() function, but unfortunately it doesn't allow me to activate multiple piezo elements simultaneously. I've been told it is a "piezo buzzer"., and being lazy, I thought I could just get rid of the "piezo" So right now, I'm looking for a way to re-use the same timer, or maybe another way to change the volume of the buzzer with code. Switch to pin 3 and play a low volume noteīut everytime I call tone.begin(pin), it eats a new timer instead of using the same. In order to change the pin, I thought I could just call tone.begin(pin) like this : #include I'm using Tone library ( Google Code Archive - Long-term storage for Google Code Project Hosting.). ![]() Playing the tone on pin 3 would give me a low volume.Playing the tone on pin 2 would give me a high volume.In this example, I would have 2 pins controlling one buzzer, each pin would be connected to a different resistor value.That way : I can control the volume by changing the value of the resistor of each buzzer, and I thought of doing something like the attached picture. So far, I've got it working, but I would like to adjust the volume of my buzzers depending on the velocity of the notes. Bascially, it reads midi files from an SD card and play the notes on differents piezo buzzers. */ # include "pitches.I'm working on my first 'big' arduino project, which is a midi file player. ![]() * Melody Plays a melody circuit: - 8 ohm speaker on digital pin 8 created modified by Tom Igoe This example code is in the public domain. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |