Let’s take a look at the motor control commands. On the waddle bot, positive number move the robot forward, negative numbers move the robot backwards. The direction in which the motor rotates is based on if the integer is positive or negative. This scale is easier for humans to understand and the NXT uses that number to determine how much power to send to the motor. It sets up a numerical scale from +100 to -100 where 0 is no power and 100 is full power. RobotC controls this power by using special variables. The more power the NXT provides, the faster the motor will rotate. The only thing the NXT can do is send electric power to an attached motor. The NXT brick can’t move without the assistance of external motors. We’ll talk more about variables as we use them. You want to quickly adjust a parameters.You need to store something for use later.You need to use the same data value more than once.A good rule of thumb is that you should only use variables in the following situations: The NXT has a limited amount of memory and you should get into the habit of writing the most efficient programs possible. Every time you create a variable, a section of system memory is allocated to that variable. While variables are useful, you should only use them when appropriate. RobotC Rule 5: The type of data stored in a variable is only defined when you create a variable. This behavior means that you don’t need to specify type when modifying a variable. When modifying a variable, RobotC requires that you use the same data type. Once you have created the variable, you can change the value stored with the same command you used to create the variable. Value: The data that is being stored in the variable.Equals sign: This separates the label from the value.Make sure to use a name that is not already in use elsewhere. Label: This allows us to reference the data later.Type: The type of data that is being stored.Later, when we set the parameter of our wait1Msec command as “timer1” the effective result is that the wait timer is set to 1000.Ī variable declaration has four main elements: In our example, we create the “timer1” variable and set it to 1000. When you use a variable as a parameter of a function, the value of that variable is passed to the function. Once we create this variable, the data contained can be referenced multiple times. In programming, a variable is a labeled section of memory that holds a specific data value. If you make changes to your NXT, you can come back to the Motor and Sensor Setup tool to update the configuration. These instructions let the NXT know that there are peripherals attached. ![]() Once you Press “OK” in this menu, you should get the following instructions at the top of your program: Here a screenshot of what the Motor tab looks like for the sample program. The Right motor is in Port C which is motorC. On our robot, the left motor is in Port A which is motorA in this tool. We don’t need to modify any other settings. This tool will not generate #pragma commands for unlabeled devices. The only thing we need to do in that screen is label our motors. To access this tool, go to the following menu location: To make writing programs easier, RobotC provides a tool to generate the configuration commands. RobotC Rule 4: A #pragma command is required for each connected device you wish to use. #pragmaīefore you use a motor, you must configure the NXT to access it. WaddleBot C1-U1-P1 from Devin Hunter on Vimeo.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |