> For the complete documentation index, see [llms.txt](https://htooaunklinn-organization.gitbook.io/htooaunklinn-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://htooaunklinn-organization.gitbook.io/htooaunklinn-docs/hardware-and-iot/arduino-on-macos/level-3.md).

# Level 3

<figure><img src="https://3422137941-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJ1pJMMB2xXaxqLgUEeCs%2Fuploads%2FWMfPw697NrHZMr3CCwpe%2Fc.png?alt=media&amp;token=4ca10883-582d-4dd0-a5d9-903d9ba41943" alt="" width="375"><figcaption></figcaption></figure>

```cpp
const int buzzer = 11;

void setup() {
  pinMode(buzzer, OUTPUT);
}

void loop() {
  tone(buzzer, 1000);
  delay(500);
  noTone(buzzer);
  delay(500);
}
```

```cpp
const int buzzer = 11;

int melody[] = {
  264, 264, 297, 264, 352, 330, // "Happy Birthday to You"
  264, 264, 297, 264, 396, 352, // "Happy Birthday to You"
  264, 264, 528, 440, 352, 330, 297, // "Happy Birthday Dear (Name)"
  466, 466, 440, 352, 396, 352 // "Happy Birthday to You"
};

int noteDurations[] = {
  4, 8, 4, 4, 4, 4,
  4, 8, 4, 4, 4, 4,
  4, 8, 4, 4, 4, 4, 4,
  4, 8, 4, 4, 4, 4
};

void setup() {
  pinMode(buzzer, OUTPUT);
}

void loop() {
  for (int i = 0; i < 25; i++) {
    int noteDuration = 1000 / noteDurations[i];
    tone(buzzer, melody[i], noteDuration);
    delay(noteDuration * 1.3);
    noTone(buzzer);
  }

  delay(2000);
}
```
