In the RobotC software we could make the robot wait for a couple of seconds by using the wait function. This will give the motors a chance to work and this will actually move the robot.
- 02 Mar 2017
Between line 8 and 9 we add the function "wait1Msec". This means "wait for 1 millisecond" and by setting the parameter to 1000 we will wait 1 millisecond a 1000 times.
Currently the program that's running on the robot is just setting motor 2 to power 50 and motor 3 to power of 50. And it's ending. And to make the robot move we must use a wait function. So, let's look at the wait functions.
This here is the program and in this program at the end between the line 8 and 9 we add the function 'wait1Msec'. Now, it's a strange name. We know, we don't like this kind of naming. But let's continue with this. It's a strange name 'wait1Msec'. Well, it's strange because in all the other programming languages, most of them is just a function called 'wait'. But here we have it as 'wait1Msec'. So 'wait1Msec' 1000. This means wait one milliseconds 1000 times. Which is wait for 1000 milliseconds. Which is actually 1 second. And we wait for 1 second. Download and run our program.
Downloading... And the robot moves for about a second. Again. Actually for 1000 milliseconds.
You have your first robot moving. Download, run the program, experiment, try to accomplish the tasks and move it forward for a different number of seconds. Just experiment with the different wait functions.
Курсове и занятия включващи този Урок
Този Урок е използван в следните курсове и занятия.