arduino                
            Uscita audio
        
        
            
    Ricerca…
Parametri
| Parametro | Dettagli | 
|---|---|
| altoparlante | Dovrebbe essere un'uscita a un altoparlante analogico | 
Uscite delle note di base
#define NOTE_C4  262 //From pitches.h file defined in [Arduino Tone Tutorial][1]
int Key = 2;
int KeyVal = 0;
byte speaker = 12;
void setup()
{
  pinMode(Key, INPUT);  //Declare our key (button) as input
  pinMode(speaker, OUTPUT);
}
void loop()
{
  KeyVal = digitalRead(Key);
  if (KeyVal == HIGH) {
    tone(speaker, NOTE_C4); //Sends middle C tone out through analog speaker
  } else {
    noTone(speaker); //Ceases tone emitting from analog speaker
  }
  delay(100);
}
 [1]: https://www.arduino.cc/en/Tutorial/toneMelody
Modified text is an extract of the original Stack Overflow Documentation
        Autorizzato sotto CC BY-SA 3.0
        Non affiliato con Stack Overflow