Chanfreinage des tons sur Plusieurs sorties à l'aide de la tonalité() fonction avec Arduino

This example shows how to use the tone() command to play different notes on multiple outputs.

The tone() command works by taking over one of the Atmega’s internal timers, setting it to the frequency you want, and using the timer to pulse an output pin. Since it’s only using one timer, you can only play one note at a time. You can, however, play notes on multiple pins sequentially. To do this, you need to turn the timer off for one pin before moving on to the next.

Thanks to Greg Borenstein for clarifying this.

Circuit

Arduino tones on Multiple outputs

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematic

Arduino tones on Multiple outputs schematic

Code

The sketch below plays a tone on each of the speakers in sequence, turning off the previous speaker first. Note that the duration of each tone is the same as the delay that follows it.

Here’s the main sketch:

/*
Multiple tone playerPlays multiple tones on multiple pins in sequence

circuit:
* 3 8-ohm speaker on digital pins 6, 7, and 8

created 8 March 2010
by Tom Igoe
based on a snippet from Greg Borenstein

This example code is in the public domain.

Major Components in Project

Hardware Required

  • (3) 8-ohm speakers
  • (3) 100 ohm resistor
  • breadboard
  • hook up wire

For more detail: Chanfreinage des tons sur Plusieurs sorties à l'aide de la tonalité() fonction avec Arduino


A Propos De L'Auteur

Ibrar Ayyub

Je suis expérimenté, rédacteur technique, titulaire d'une Maîtrise en informatique de BZU Multan, Pakistan à l'Université. Avec un arrière-plan couvrant diverses industries, notamment en matière de domotique et de l'ingénierie, j'ai perfectionné mes compétences dans la rédaction claire et concise du contenu. Compétent en tirant parti de l'infographie et des diagrammes, je m'efforce de simplifier des concepts complexes pour les lecteurs. Ma force réside dans une recherche approfondie et de présenter l'information de façon structurée et logique format.

Suivez-Nous:
LinkedinTwitter

Laisser un Commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

fr_FRFrench
Faire défiler vers le Haut