EV3: Move Forward Until Object

by babesandrew in Circuits > Robots

501 Views, 0 Favorites, 0 Comments

EV3: Move Forward Until Object

Screen Shot 2022-10-16 at 9.34.46 PM.png

The instruction set created is for beginner programmers who are wanting to gain and introduction on robotics. Lego's EV3 robot is one of the best ways to interact with robotics while improving your programming skills. In this task we will go through what is needed for the instruction, from the requirements and supplies needed to the step by step process to finally moving your robot forward until it touches an object.

Supplies

Screen Shot 2022-10-16 at 9.41.18 PM.png
Screen Shot 2022-10-16 at 9.41.52 PM.png

We will need

  1. Lego Mindstorm Ev3 Robot
  2. A computer with windows operating system.
  3. Robot C Programming
  4. Robot C Virtual Worlds(If you do not want to buy the robot).

Downloading Robot C

Screen Shot 2022-10-16 at 9.46.55 PM.png

Step1:

You must go to https://www.vexrobotics.com/robotc-vexedr-vexiq.html and download the windows exe at the bottom right corner. This is the programming Language needed to code your Robot C.

Downloading Robot C Virtual Worlds

Screen Shot 2022-10-16 at 9.50.09 PM.png
Screen Shot 2022-10-16 at 9.50.33 PM.png

Step 2:

You must go to https://www.robotvirtualworlds.com/ and scroll down to the bottom of the page and pay for the full virtual worlds. If you do not have the robot, this is very much needed in order to continue your Robot C development. However, if you are only using the virtual worlds to do this instruction set than only download the free trial.

Building Your EV3 Robot

Screen Shot 2022-10-16 at 9.59.31 PM.png
Screen Shot 2022-10-16 at 9.59.54 PM.png
Screen Shot 2022-10-16 at 10.00.20 PM.png

Step 3:

We begin to open our box and start to construct our EV3, but if you decided to not build a lego Ev3 you may skip to step Six and start coding your EV3 robot. Otherwise, follow the instructions to build your Lego Mind storm EV3.

Charging Your Ev3 Robot

418wfG0qyOL._AC_SY580_.jpg
maxresdefault.jpg

Step 4:

Plug the Charger into your nearest outlet and connect to the battery of the EV3 robot. The Charging time usually takes around 3 hours.

Connect Robot to Computer

download.jpg
images2.jpg

Step 5:

Connect your EV3 Robot to your computer with the pc to usb cable that comes with the robot. Be sure your computer is turned on and you are logged into a computer that has Robot C application.

Double Click Robot C Application

Screen Shot 2022-10-16 at 10.13.42 PM.png

Step 6:

We are now beginning to start up our Robot C Application, so first begin to double click the application and start up our programs. As you can see, for me my application is on the bottom left corner, it will appear different for everyone else. If you are unable to find it go to the search bar at the bottom left corner and search Robot C and it should pop up.

Open New File

Screen Shot 2022-10-16 at 10.16.50 PM.png

Step 7:

We are then going to open a new file to start coding and editing our program for our robot.

Code

Step 8:

Be Sure to copy and paste all the configurations for each of the motors

#pragma config(Sensor, S1,   touchSensor,  sensorEV3_Touch)

#pragma config(Sensor, S2,   gyroSensor,   sensorEV3_Gyro, modeEV3Gyro_RateAndAngle)

#pragma config(Sensor, S3,   colorSensor,  sensorEV3_Color, modeEV3Color_Color)

#pragma config(Sensor, S4,   sonarSensor,  sensorEV3_Ultrasonic)

#pragma config(Motor, motorA,     armMotor,   tmotorEV3_Large, PIDControl, encoder)

#pragma config(Motor, motorB,     leftMotor,   tmotorEV3_Large, PIDControl, driveLeft, encoder)

#pragma config(Motor, motorC,     rightMotor,  tmotorEV3_Large, PIDControl, driveRight, encoder)

Then were are going to add the code into the main task and type in


task main()

{

setMultipleMotors(20,motorB,motorC);

waitUntil(getTouchValue(touchSensor) == 1);

setMultipleMotors(0,motorB,motorC);

}


This will move the robot forward at a speed of 20 until it touches an object which then stops the robot.

Download to Robot

Screen Shot 2022-10-16 at 11.07.23 PM.png

Step 9:

We are then going to download the code into our robot by clicking the download to robot icon in the programs.

If we are testing in virtual worlds we have to change. We will click robot and changing the testing location from robot to Virtual worlds.

If we are testing with an actual robot we want to do a firmware download to download directly into the robot.

Test Robot

Step 10:

If you are running on virtual worlds. Click on the test move forward until object and there you will receive a badge once the task is completed.

Otherwise, if you are testing in real life. Have your robot move forward until and object. If it stops that means the robot works and you completed the task.

Conclusion

Conclusion:

The robot is complete and testing is now finished you could continue to try out other task that are online.