コンテンツへスキップ

Lesson 9: Sound and functions

English

A buzzer

  • tone(8, 440); makes pin 8 switch on and off 440 times a second. A buzzer plays the note A.
  • tone(8, 440, 500); plays it for 500 ms. noTone(8); stops it.
  • Press the 🔇 button on the board to hear it.
void setup() {
  tone(8, 262, 300);   // C
  delay(400);
  tone(8, 330, 300);   // E
  delay(400);
  tone(8, 392, 300);   // G
}

void loop() {
}

ログインまたはアカウント作成

IGCSE, A-Level & AP