How To Make Ev3 Follow A Black Line
Line Following
Introduction
Brand your LEGO® MINDSTORMS® Education EV3 robot follow a line using the Color Sensor's Reflected Low-cal Intensity Mode.
Footstep 1
In the ||logic:Logic|| Toolbox drawer under the Conditionals section, drag out an ||logic:If then else|| cake onto the Workspace, and drop it into the ||loops:forever|| loop.
forever(function () { if (true) { } else { } }) Step 2
Open up the ||logic:Logic|| Toolbox drawer again. From the Comparison section, elevate out ||logic:0 < 0|| comparison cake and drop it into the ||logic:if so else|| cake, replacing truthful.
forever(function () { if (0 < 0) { } else { } }) Pace 3
Open the ||sensors:Sensors|| Toolbox drawer. Elevate out a ||sensors:color sensor light|| value block and drib it into the 2d slot of the ||logic:0 < 0|| comparison block, replacing the 2nd 0.
forever(function () { if (0 < sensors.color3.low-cal(LightIntensityMode.Reflected)) { } else { } }) Step iv
If the value of the reflected light is greater than xl% (white or very light), our robot is outside the line, so steer to the left. In the ||logic:0 < 0|| comparison block modify the first compared value from 0 to 40.
forever(part () { if (40 < sensors.color3.light(LightIntensityMode.Reflected)) { } else { } }) Step v
Open the ||motors:Motors|| Toolbox drawer. Drag out 2 ||motors:tank motors|| blocks and drop one of them into the ||logic:if|| role, and the other into the ||logic:else|| role of the ||logic:if and so else|| block.
forever(function () { if (40 < sensors.color3.low-cal(LightIntensityMode.Reflected)) { motors.largeBC.tank(50, 50) } else { motors.largeBC.tank(l, fifty) } }) Stride half dozen
In the kickoff ||motors:tank motors|| block in the ||logic:if|| clause, change the speed values of the motors from l%, fifty% to v%, fifteen%. This slows downwards the robot and steers it to the left (because the C motor is driving faster than the B motor).
forever(function () { if (twoscore < sensors.color3.light(LightIntensityMode.Reflected)) { motors.largeBC.tank(5, xv) } else { motors.largeBC.tank(fifty, l) } }) Pace seven
In the second ||motors:tank motors|| block in the ||logic:else|| clause, change the speed values of the motors from l%, fifty% to 15%, 5%. This slows down the robot and steers it to the right (because the B motor is driving faster than the C motor).
forever(function () { if (40 < sensors.color3.lite(LightIntensityMode.Reflected)) { motors.largeBC.tank(five, 15) } else { motors.largeBC.tank(15, 5) } }) Step 8
Use the EV3 simulator to effort out your code.
Motion the slider under the Color Sensor to modify the reflected calorie-free intensity and cheque that motors are moving as you would expect.
Step 9
Plug your EV3 Brick into the computer with the USB cable, and click the Download button at the lesser of your screen. Follow the directions to relieve your program to the EV3 Brick.
Adhere a Color Sensor to Port iii of your EV3 Brick, and attach your brick to a driving base of operations with large motors attached to Ports B and C. See the instructions for edifice a Driving Base of operations with Colour Sensor Downwardly. Test your program by positioning your robot to the right of a dark, thick line then permit it drive!
Source: https://makecode.mindstorms.com/tutorials/line-following

0 Response to "How To Make Ev3 Follow A Black Line"
Post a Comment