Variables
5 Minutes · Module 6 - Upgrading Robot
Robotic simulation variables for kids: learn how to use a variable and if condition to move disks in a playground. A Tamil robotics lesson.
- Turn and drive blocks to reach red and green disk positions
- Repeating the disk-moving program using a repeat block
- Using a disk variable and if condition to stop extra steps
What this lesson teachesRead the lesson as text
A variable is a storage location used in computer programming to hold a value that can be modified or updated while a program runs. In robotics, variables allow a robot to track counts or measurements and use conditional logic to decide when specific actions should happen or stop.
Moving between disk positions
- Turn right by 90 degrees to orient toward the next colored disk area.
- Drive forward for 800 mm to travel from one colored disk position to the next.
- Turn left by 90 degrees to face the target disks in the playground.
- Increase both drive velocity and turn velocity to 100 so the robot moves faster.
The repeating movement problem
Placing the collection routine inside a repeat block set to three allows the robot to gather the blue, red, and green disks. However, after clearing all three colors, the robot executes the turning and driving commands a third time even though no more disks remain. These transition steps only need to happen twice, meaning the final repetition makes the robot turn and drive away from where it should stop.
Creating and updating a variable
Under the variables menu, creating a variable named disk establishes a dedicated storage location in memory. The program sets this disk variable to zero before the movement begins. Each time the robot finishes a disk-moving cycle, a change block increases the variable value by one so the program continuously tracks how many cycles have occurred.
Controlling steps with an if condition
An if-then block paired with a less-than operator checks whether the value of the disk variable is less than two. During the first cycle, the disk variable increases from zero to one, allowing the robot to turn and advance to the next position. On the second cycle, the variable reaches two, which fails the less-than-two check and prevents the unnecessary final repositioning steps from running.
Part of the course
ROBOTIC SIMULATION