# Make HaloCode the Steering Wheel of the Car on Stage

**Programming Result**

When you tilt HaloCode to the left, the car on stage will move leftward. When you tilt HaloCode to the right, the car will move rightward. HaloCode is just like the steering wheel of the car.

![](/files/-Lpg9dlSkTnONsuIyzwZ)

**Use the motion sensor**

The motion sensor of HaloCode detects how HaloCode moves. We'll use the motion sensor in this example. When HaloCode is tilted to the left, a corresponding piece of message will be sent to the car on Scratch Stage to make it move leftward. Likewise, when HaloCode is tilted to the right, a corresponding piece of message will tell the car to move rightward.

1\. Drag a Control block if () then () to the Scripts area. Add a Sensing block HaloCode is ()? to the condition.

![](/files/-Lpg9dlTjrpAeIrwuEUL)

2\. Likewise, for the right side, duplicate the script, and select "right-tilted".

![](/files/-Lpg9dlUmIkigRfGsSp1)

**Message broadcast**

3\. Add two Events blocks broadcast (). Create two pieces of message, namely "left" and "right".

![](/files/-Lpg9dlVOP6FPBYm9Tp-)

4\. Add an Events block when button is pressed and a Control block forever.

**Add a sprite**

5\. Under "Sprites", click "+". In the Sprites Library, choose "Car" from the Transportation category.

6\. Delete the default sprite "Panda".

**Program the car**

7\. Add three Motion block: set rotation style (left-right), point in direction (-90), move (10) steps.

8\. Add an Events block when I receive (), and choose message "left". When the car receives message "left", it will move leftward for 10 steps.

10\. Likewise, for the rightward part, duplicate the script. Choose message "right", and change the direction to "90".

**Note: the message received should be the same message that is broadcast.**

![](/files/-Lpg9dlW1flZ510YMDpK)

11\. Press the button of HaloCode and then tilt it!


---

# 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/halocode-1/code-with-mu-a-simple-python-editor/examples/level-up/make-halocode-the-steering-wheel-of-the-car-on-stage.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.
