# Speaker

Codey's on-board speaker enables Codey to play sound. You can write music, add sound effects, and do other fun stuff with Codey's speaker.

### 1. play sound () <a href="#id-1-play-sound" id="id-1-play-sound"></a>

Make Codey's speaker play a specified sound.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-1-1.png)

| Sound Effect |          |            |             |             |          |         |
| ------------ | -------- | ---------- | ----------- | ----------- | -------- | ------- |
| hello        | hi       | bye        | yeah        | wow         | laugh    | hum     |
| sad          | sigh     | annoyed    | angry       | scared      | pettish  | curious |
| embarrassed  | ready    | sprint     | snore       | meow        | start    | switch  |
| beeps        | buzz     | air-out    | explosion   | gotcha      | painful  | jump    |
| laser        | level-up | low-energy | metal-clash | prompt-tone | right    | wrong   |
| ringtone     | score    | shot       | step\_1     | step\_2     | activate | warning |

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-1-2.png)

Press Button A. Codey will play the sound "hello".

### 2. play sound () until done <a href="#id-2-play-sound--until-done" id="id-2-play-sound--until-done"></a>

Make Codey's speaker play a specified sound, and wait until it's done.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-2-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-2-2.png)

Press Button A. Codey will play the sound "hello".

### 3. stop all sounds <a href="#id-3-stop-all-sounds" id="id-3-stop-all-sounds"></a>

Make Codey's speaker stop playing all sounds.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-3-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-3-2.png)

Press Button A. Codey will play the sound "hello" for 10 times, and then stop all sounds.

### 4. play note () for () beats <a href="#id-4-play-note--for--beats" id="id-4-play-note--for--beats"></a>

Make Codey's speaker play a specified note for specified number of beats.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-4-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-4-2.png)

Press Button A. Codey will play the note "C4" for 0.25 beat.

### 5. rest for () beats <a href="#id-5-rest-for--beats" id="id-5-rest-for--beats"></a>

Make Codey's speaker stop playing sounds and wait for specified number of beats.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-5-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-5-2.png)

Press Button A. Codey will play the note "C4" for 0.25 beat 5 times, and after waiting for 0.25 beat, play the note "G4" for 0.25 beat 5 times.

### 6. play sound at frequency of () HZ for () secs <a href="#id-6-play-sound-at-frequency-of--hz-for--secs" id="id-6-play-sound-at-frequency-of--hz-for--secs"></a>

Make Codey's speaker play sound at specified frequency for a specified period of time.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-6-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-6-2.png)

Press Button A. Cody will play a 700Hz sound for one second.

### 7. change volume by () <a href="#id-7-change-volume-by" id="id-7-change-volume-by"></a>

Change the sound volmue of Codey's speaker. Input positive number to increase sound volume, or negative number to decrease sound volume.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-7-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-7-2.png)

Press Button A to decrease sound volume of Codey's speaker by 10.

### 8. set volume to ()% <a href="#id-8-set-volume-to" id="id-8-set-volume-to"></a>

Set the sound volume of Codey's speaker to specified percentage (0 \~ 100).

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-8-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-8-2.png)

When Codey starts up, the sound volume of the speaker will be set to 60%.

### 9. volume <a href="#id-9-volume" id="id-9-volume"></a>

Report the sound volume of Codey's speaker.

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-9-1.png)

**Example:**

![](http://docs.makeblock.com/codeyrocky/en/block-reference/images/speaker-9-2.png)

Press Button A. The current sound volume of Codey's speaker will be displayed on the screen.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.pakronics.com.au/primary/codey-rocky-ai-robot/block-reference/speaker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
