# Programming for the Ev3

```
#!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
                                 InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import Port, Stop, Direction, Button, Color
from pybricks.tools import wait, StopWatch, DataLog
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile


# This program requires LEGO EV3 MicroPython v2.0 or higher.
# Click "Open user guide" on the EV3 extension tab for more information.


# Create your objects here.
ev3 = EV3Brick()


# Write your program here.
ev3.speaker.beep()

```

### Basic Drivetrain Setup:

{% embed url="<https://youtu.be/8IGgU4YXz3U>" %}

### Defining our own functions:

{% embed url="<https://youtu.be/Du0J7oH-IcI>" %}

### Basic Sensor Setup:

{% embed url="<https://youtu.be/6mO5Rc2Dhn0>" %}

{% embed url="<https://youtu.be/IR5wr22c8Lo>" %}

{% embed url="<https://youtu.be/evo4L0xoSfU>" %}


---

# 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://gilmour.online/compsci/robotics-7/programming-for-the-ev3.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.
