2018-02-27 00:16:17 +01:00
# Use
Build a robot and drive into the world of robotics!
2018-03-22 22:16:14 +01:00
![EV3 Driving Base full w/cuboid ](/static/getting-started/EV3_GettingStarted_13.jpg )
2018-03-21 20:36:49 +01:00
In this project we will guide you through building a Driving Base Robot and programming it to move straight and turn. You will also build and Object Detector Module, and program it to detect an object. It’ s a good idea to have done the [Try ](/getting-started/try ) sequence first.
2018-02-27 00:16:17 +01:00
## Connect
What if your school had a multipurpose robot? How would you use it?
2018-03-22 22:16:14 +01:00
![Apple Picker Robot ](/static/getting-started/02_ApplePickerRobot.jpg )
2018-02-27 00:16:17 +01:00
Would you use it to clean the school or plant trees?
## Build Your Driving Base Robot
2018-03-21 20:36:49 +01:00
Build the robot driving base:
2018-02-27 00:16:17 +01:00
2018-03-21 20:36:49 +01:00
[![EV3 Driving Base ](/static/lessons/common/ev3-driving-base.jpg )](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-driving-base-79bebfc16bd491186ea9c9069842155e.pdf)
2018-02-27 00:16:17 +01:00
## Make It Move
2018-03-22 22:16:14 +01:00
**Code it:** Create a program that makes the Driving Base move forward and stop at the finish line, which is ``1`` meter away.
2018-02-27 00:16:17 +01:00
Start by building this program:
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(0, 50, 1, MoveUnit.Rotations)
})
```
2018-03-24 00:26:46 +01:00
* Drag a ``||motors:steer large motors B+C||`` block inside an ``||brick:on button||`` block.
2018-03-22 22:16:14 +01:00
* Click on the ** (+)** sign.
* Change to ``1`` rotation.
2018-02-27 00:16:17 +01:00
2018-03-21 20:36:49 +01:00
### ~hint
2018-02-27 00:16:17 +01:00
2018-03-21 20:36:49 +01:00
**Hint:** You will have to modify the number of rotations until you find the number that matches the robot moving forward 1 meter and stopping.
2018-02-27 00:16:17 +01:00
### ~
2018-03-22 22:16:14 +01:00
**Download:** Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
2018-02-27 00:16:17 +01:00
## Make It Turn
2018-03-22 22:16:14 +01:00
**Code it:** Create a new program that turns the Driving Base 180 degrees.
2018-02-27 00:16:17 +01:00
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(-50, 50, 1, MoveUnit.Rotations)
})
```
2018-03-21 20:36:49 +01:00
### ~hint
2018-02-27 00:16:17 +01:00
2018-03-21 20:36:49 +01:00
**Hint:** You will have to modify the turn ratio and the number of rotations until the robot reaches 180 degrees.
2018-02-27 00:16:17 +01:00
### ~
2018-03-22 22:16:14 +01:00
**Download:** Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
2018-02-27 00:16:17 +01:00
## Add an Ultrasonic Sensor to Your Driving Base
2018-03-22 22:16:14 +01:00
Build and attach an Ultrasonic Sensor to your driving base:
2018-02-27 00:16:17 +01:00
2018-03-22 22:16:14 +01:00
[![EV3 Ultrasonic Sensor Driving Base Building Instructions Main Image ](/static/lessons/common/ev3-ultrasonic-sensor-driving-base.jpg )](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-ultrasonic-sensor-driving-base-61ffdfa461aee2470b8ddbeab16e2070.pdf)
2018-02-27 00:16:17 +01:00
## Detect an Object
2018-03-22 22:16:14 +01:00
**Code it:** Create a program that moves the Driving Base and makes it stop ``6`` cm from the Cuboid.
Create a new program:
2018-02-27 00:16:17 +01:00
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.tank(50, 50)
sensors.ultrasonic4.setThreshold(UltrasonicSensorEvent.ObjectDetected, 6)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectDetected);
motors.stopAll()
})
```
2018-03-24 00:26:46 +01:00
* Drag a ``||motors:tank large motors B+C||`` motor block inside the ``||brick:on button||`` block.
2018-03-22 22:16:14 +01:00
* Drag the Ultrasonic Sensor threshold ``||sensors:set ultrasonic 4||`` block and place it below the motor block.
* Drag a ``|sensors:pause until ultrasonic 4||`` block and place it under the threshold block.
* Drag a ``||motors:stop all motors||`` block and place it below the sensor block.
2018-02-27 00:16:17 +01:00
2018-03-21 20:36:49 +01:00
### ~hint
2018-02-27 00:16:17 +01:00
2018-03-21 20:36:49 +01:00
**Hint:** You will have to modify the values of the Ultrasonic Sensor block until the robot reaches the desired position.
2018-02-27 00:16:17 +01:00
### ~
2018-03-22 22:16:14 +01:00
**Download:** Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
2018-02-27 00:16:17 +01:00
2018-03-21 20:36:49 +01:00
Click on the **JavaScript** tab. Change and test the number value of the Ultrasonic
Sensor.
2018-02-27 00:16:17 +01:00
```typescript
sensors.ultrasonic4.setThreshold(UltrasonicSensorEvent.ObjectDetected, 10)
```
**Congratulations!**
You are ready to move on to the next steps.
2018-03-22 22:16:14 +01:00
Try a LEGO MINDSTORMS [Design Engineering ](/design-engineering ), [Coding ](/coding ), or [Maker ](/maker ) activity.