Simple Behaviors

3 minutes
Share the link to this page
Copied
  Completed
We look at how to use all the "Simple Behavior" commands like Forward, turnLeft and so on in this lesson. This should be a review if you've been using RobotC for a while.

Transcript

The simple bi vs can be found under the natural language tab. These are pre made functions included in robot C, and they make programming easier for us to use them is as easy as dragging and dropping them into the editor. That will give us the basic command, but we still need to set the parameters. The first parameter is quantity, which is just a number. The second is the unit we want to measure. It can be rotations degrees or time based, like milliseconds, seconds or minutes.

The third parameter is the motor speed as a percentage. The sample program here will make the robot drive forward for two motor shaft rotations. If the wheels are directly on the motor shaft and you are using the regular 200 millimeter diameter wheels, the robot will move 400 millimeters forward at 50% speed, it will then turn left about 90 degrees. Also add 50% speed. To move the arm and claw, we'll use the Move motor command. When we use this command, we need to specify which motor we want to move, then how much we want to move it.

And we also have a choice of units we can use. Likewise, the last parameter is the speed. By using the same logic, you can now add backward, turn right and the claw open and close commands to your program. That will be our first mini challenge. But let's look at something else first. The green text in this program is called commenting.

Comments are used to explain to others what the program does. It will also help you remember this at Some later stage, two forward slashes are used for this thing, single line comment and forward slash star. Then the comment followed by star forward slash is used for multi line comments. Comments are for humans, the robot ignores them. Because of this, we can also use comments to make the robot ignore parts of a program. Then when we want to put that step back in the program, we can just uncomment it, which is better and faster than deleting and rewriting the code.

Once you're done writing your program, you can give it a good name. Save it in a location that you can find again, and download it to your robot. use simple behaviors to write a program that makes the robot drive forward, reverse, turn left and right. Move the arm up and down. Then open and close. The claw.

Don't forget to write comments to explain your code to others. This is what your robot should do in the mini challenge.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.