You are on page 1of 4

Department Of Electrical Engineering

CS-114 Fundamentals Of Programming

LAB 11: Introduction to LEGO Mindstorms &the Virtual


Robotics Toolkit

TASK 1:
Write a program that makes a robot drive forward by repeating three different sounds
until the color sensor detects the color tape you are using.

STEPS:
 First of all, add a start block (if it’s not already chosen) from the family of flow
blocks. This block basically initiates the program.
 Attach a steering block (action block) and this time, set the mode to ON.
 Then attach a loop block and choose the colour sensor mode from the menu.
Select a colour of your choice. (In this case, red has been selected)
 Attach switch block. In the upper part, attach a stop block from the family of flow
blocks. In the lower part, attach a sound block (action block) and select a sound of
your choice. This means that if the robot indicates the colour RED, the robot will
stop. Otherwise it will make the selected sound.
 Repeat the above step two times.

 Connect wifi and click on the play button.

PROGRAM:
TASK 2:
Write a Code for following a line using one light sensor.
(Hint: Using switch and loop block).

STEPS:
 First of all, add a start block (if it’s not already chosen) from the family of flow
blocks. This block basically initiates the program.
 Then attach a loop block (flow block).
 Attach switch block. In the upper part, attach a steering block (action block) and
set the mode to ON. In the lower part, attach a stop block from the family of flow
blocks.

 Connect wifi and click on the play button.


TASK 3:
Write a code for following a line using two light sensors.
(Hint: Using 3 switch blocks and 1 loop block).

STEPS:
 First of all, add a start block (if it’s not already chosen) from the family of flow
blocks. This block basically initiates the program.
 Then attach a loop block (flow block).
 Attach switch block. In the upper part, attach a steering block (action block). In
the lower part, attach another switch block. In the upper part, attach a steering
block (action block). And in the lower one, attach a stop block.
 Attach a steering block between switch and loop blocks.

 Connect wifi and click on the play button.

PROGRAM:

You might also like