diff --git a/Controlling-a-Servo-(Blocks).md b/Controlling-a-Servo-(Blocks).md index 29956e4..5e89021 100644 --- a/Controlling-a-Servo-(Blocks).md +++ b/Controlling-a-Servo-(Blocks).md @@ -26,30 +26,30 @@ Note that it will take an estimated 20 minutes to complete this task. | Modifying the Op Mode to Control a Servo Motor | | ---- | -| 1. Place the Robot Controller in Programming Mode. Verify that your laptop is still connected to the Robot Controller’s Programming Mode Wi-Fi network.

| -| 2. Verify that “MyFIRSTOpMode” is opened for editing. If it is not, you can click on the FIRST logo in the upper left-hand corner of the browser window on the laptop. This should take you to the main FTC Blocks Development Tool project screen.

Click on the “MyFIRSTOpMode” project to open it for editing if it is not already opened. | -| 3. On the left-hand side of the screen click on the category called “Actuators” and look for the subcategory called “Servos”.

| -| 4. Select the “set servoTest.Position to” block from the list of available Servo blocks.

| -| 5. Drag the “set servoTest.Position to” block to the spot just under the comment block that reads “Put initialization blocks here.” The block should click into place.

| -| 6. Click on the number block ”0” and change the block’s value to “0.5”.

When a user selects this op mode, the servo position will initially be set to the midway point (90-degree position). | -| 7. Click on the “Logic” category of the programming blocks and select the “if do” block from the list of available blocks. Drag the block to the position immediately after the comment block that reads “Put loop blocks here.”

The block should click into place. | -| 8. Click on the “Gamepad” category of the programming blocks and select the “gamepad1.Y” block from the list of available blocks.

Note that this block is towards the bottom of the list of blocks. You might have to scroll down to the bottom of the list before you can select this block. | -| 9. Drag the “gamepad1.Y” block to the right side of the “if do” block. The block should click into place.

The “if do” block will use the state of the gamepad1.Y value its test condition. If the “Y” button is pressed, the statements within the “do” portion of the block will be executed. | -| 10. On the left-hand side of the screen click on the category called “Actuators” and look for the subcategory called “Servos”.

The “if do” block will use the state of the gamepad1.Y value its test condition. If the “Y” button is pressed, the statements within the “do” portion of the block will be executed. | -| 11. Select the “set servoTest.Position to” block from the list of available Servo blocks.

| -| 12. Drag the “set servoTest.Position to” block so that it snaps in place in the do portion of the “if do” block.

If the “Y” button is pressed on gamepad #1, the op mode will move the servo’s position to the 0-degree position. | -| 13. Click on the blue and white Settings icon for the “if do” block. This will display a pop-up menu that lets you modify the “if do” block.

| -| 14. Drag an “else if” block from the left side of the pop-up menu and snap it into place under the “if” block.

Drag a second “else if” block from the left side and snap it into place on the right side under the first “else if” block. | -| 15. Click on the Settings icon to hide the pop-up menu for the “if do” block. The “if do” block should now have two “else if” test conditions added.

| -| 16. Click on the “Logic” category and select the logical “and” block.

| -| 17. Drag the “and” block so it clicks in place as the test condition for the first “else if” block.

| -| 18. Click on the word “and” and select “or” from the pop-up menu to change the block to a logical “or” block.

| -| 19. Click on the “Gamepad” category and select the “gamepad1.X” block. Drag the block so that it clicks in place as the first test condition of the logical “or” block.

| -| 20. Click on the “Gamepad” category and select the “gamepad1.B” block. Drag the block so that it clicks in place as the second test condition of the logical “or” block.

| -| 21. Select a “set servoTest.Position to” block and place it into “do” clause of the first else-if block.

| -| 22. Highlight the number “0” and change it to “0.5”. With this change, if the user presses the “X” button or “B” button on gamepad #1, the op mode will move the servo to the midway (90-degree) position.

| -| 23. Use a “gamepad1.A” block as the test condition for the second “else if” block. Drag a “set servoTest.position to” block to the do clause of the second “else if” block and modify the numeric value so that the servo’s position will be set to a value of 1.

For this clause, if the “A” button is pressed on the #1 gamepad, the op mode will move the servo to the 180-degree position. | -| 24. Insert a “call telemetry.addData” block (numeric) before the “call Telemetry.update” block. Rename the key field to “Servo Position” and insert a “servoTest.Position” block for the number field.

This set of blocks will send the current servo position value to the Driver Station while the op mode is running. | -| 25. Save your op mode and verify that it was saved successfully to the Robot Controller.

| -| 26. Follow the procedure outlined in the section titled [Running Your Op Mode](https://github.com/ftctechnh/ftc_app/wiki/Running-Your-Op-Mode) to run your updated op mode. Don’t forget to exit programming mode before selecting and running the op mode. Also, make sure that your gamepad is designated as User #1 before running your op mode.

You should now be able to control the servo position with the colored buttons. The servo position should be displayed on the Driver Station. | +| 1. Verify that your laptop is still connected to the Robot Controller’s Program & Manage Wi-Fi network. | +| 2. Verify that “MyFIRSTOpMode” is opened for editing. If it is not, you can click on the FIRST logo in the upper left-hand corner of the browser window on the laptop. This should take you to the main FTC Blocks Development Tool project screen.

Click on the “MyFIRSTOpMode” project to open it for editing if it is not already opened. | +| 3. On the left-hand side of the screen click on the category called “Actuators” and look for the subcategory called “Servos”.

| +| 4. Select the “set servoTest.Position to” block from the list of available Servo blocks.

| +| 5. Drag the “set servoTest.Position to” block to the spot just under the comment block that reads “Put initialization blocks here.” The block should click into place.

| +| 6. Click on the number block ”0” and change the block’s value to “0.5”.

When a user selects this op mode, the servo position will initially be set to the midway point (90-degree position). | +| 7. Click on the “Logic” category of the programming blocks and select the “if do” block from the list of available blocks. Drag the block to the position immediately after the comment block that reads “Put loop blocks here.”

The block should click into place. | +| 8. Click on the “Gamepad” category of the programming blocks and select the “gamepad1.Y” block from the list of available blocks.

Note that this block is towards the bottom of the list of blocks. You might have to scroll down to the bottom of the list before you can select this block. | +| 9. Drag the “gamepad1.Y” block to the right side of the “if do” block. The block should click into place.

The “if do” block will use the state of the gamepad1.Y value its test condition. If the “Y” button is pressed, the statements within the “do” portion of the block will be executed. | +| 10. On the left-hand side of the screen click on the category called “Actuators” and look for the subcategory called “Servos”.

The “if do” block will use the state of the gamepad1.Y value its test condition. If the “Y” button is pressed, the statements within the “do” portion of the block will be executed. | +| 11. Select the “set servoTest.Position to” block from the list of available Servo blocks.

| +| 12. Drag the “set servoTest.Position to” block so that it snaps in place in the do portion of the “if do” block.

If the “Y” button is pressed on gamepad #1, the op mode will move the servo’s position to the 0-degree position. | +| 13. Click on the blue and white Settings icon for the “if do” block. This will display a pop-up menu that lets you modify the “if do” block.

| +| 14. Drag an “else if” block from the left side of the pop-up menu and snap it into place under the “if” block.

Drag a second “else if” block from the left side and snap it into place on the right side under the first “else if” block. | +| 15. Click on the Settings icon to hide the pop-up menu for the “if do” block. The “if do” block should now have two “else if” test conditions added.

| +| 16. Click on the “Logic” category and select the logical “and” block.

| +| 17. Drag the “and” block so it clicks in place as the test condition for the first “else if” block.

| +| 18. Click on the word “and” and select “or” from the pop-up menu to change the block to a logical “or” block.

| +| 19. Click on the “Gamepad” category and select the “gamepad1.X” block. Drag the block so that it clicks in place as the first test condition of the logical “or” block.

| +| 20. Click on the “Gamepad” category and select the “gamepad1.B” block. Drag the block so that it clicks in place as the second test condition of the logical “or” block.

| +| 21. Select a “set servoTest.Position to” block and place it into “do” clause of the first else-if block.

| +| 22. Highlight the number “0” and change it to “0.5”. With this change, if the user presses the “X” button or “B” button on gamepad #1, the op mode will move the servo to the midway (90-degree) position.

| +| 23. Use a “gamepad1.A” block as the test condition for the second “else if” block. Drag a “set servoTest.position to” block to the do clause of the second “else if” block and modify the numeric value so that the servo’s position will be set to a value of 1.

For this clause, if the “A” button is pressed on the #1 gamepad, the op mode will move the servo to the 180-degree position. | +| 24. Insert a “call telemetry.addData” block (numeric) before the “call Telemetry.update” block. Rename the key field to “Servo Position” and insert a “servoTest.Position” block for the number field.

This set of blocks will send the current servo position value to the Driver Station while the op mode is running. | +| 25. Save your op mode and verify that it was saved successfully to the Robot Controller.

| +| 26. Follow the procedure outlined in the section titled [Running Your Op Mode](https://github.com/ftctechnh/ftc_app/wiki/Running-Your-Op-Mode) to run your updated op mode. Don’t forget to exit programming mode before selecting and running the op mode. Also, make sure that your gamepad is designated as User #1 before running your op mode.

You should now be able to control the servo position with the colored buttons. The servo position should be displayed on the Driver Station. |