> For the complete documentation index, see [llms.txt](https://learn.pakronics.com.au/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.pakronics.com.au/primary/codey-rocky-ai-robot/block-reference/events.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
