# Events

### 1. when Codey starts up <a href="#id-1-when-codey-starts-up" id="id-1-when-codey-starts-up"></a>

When Codey starts up, run the script.

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

**Example:**

When Codey starts up, the screen will display "hello".

### 2. when button () is pressed <a href="#id-2-when-button--is-pressed" id="id-2-when-button--is-pressed"></a>

When the specified button is pressed, run the script.

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

**Example:**

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

When Button A is pressed, Codey will play the sound "hello".

### 3. when Codey is shaking <a href="#id-3-when-codey-is-shaking" id="id-3-when-codey-is-shaking"></a>

When Codey is shaking, run the script.

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

**Example:**

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

When being shaken, Codey will play the sound "wow".

### 4. when Codey is () tilted <a href="#id-4-when-codey-is--tilted" id="id-4-when-codey-is--tilted"></a>

If Codey tilts towards the specified direction, run the script. There are four options: "tilted to the left", "tilted to the right", "ears up", and "ears down".

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

**Example:**

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

When Codey is left-tilted, the screen will display "left".

### 5. when () > () <a href="#id-5-when" id="id-5-when"></a>

When the value of the specified parameter (loudness or timer) is greater than the specified value, run the script.

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

**Example:**

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

When the loudness detected is greater than 10, Codey's screen will display current loudness.

### 6. when light intensity < () <a href="#id-6-when-light-intensity" id="id-6-when-light-intensity"></a>

When detected light intensity is less than the specified value, run the script.

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

**Example:**

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

When the light intensity detected is less than 10, Codey's LED will light up red.

### 7. when I receive () <a href="#id-7-when-i-receive" id="id-7-when-i-receive"></a>

When Codey receives specified message, run the script.

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

**Example:**

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

When receiving "message1", Codey will play the sound "laugh".

### 8. broadcast () <a href="#id-8-broadcast" id="id-8-broadcast"></a>

Broadcast specified message.

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

**Example:**

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

Press Button A. Codey will broadcast "message 1".


---

# 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/events.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.
