Define parameter inputs/outputs within the code

We are not finished yet! You will return to a screen showing your code, but now a grey block with four outputs will appear before the code. This is the final step of the parameter setup; you will use these data wires to tell the EV3 software where each of the inputs go in your code:

Recall that earlier we left the input of the subtraction blocks empty. Now, we will fill the empty inputs with the parameter data wires! The first math block calculates the difference in latitude. The subtraction order is destination position minus current position, so insert parameter a (curLat) as the second input of the math block, and insert parameter (destLat) as the first input of the math block:

We will follow the same steps for the math block that calculates the longitude difference. Again, the subtraction order is destination position minus current position, so insert parameter b (curLong) as the second input of the math block and parameter d (destLong) as the math block's first input. When correctly configured, the input parameters should be wired like so:

Earlier in this section, we discussed that you may need to add an extra math block that multiplies the position by -1. Remember that this extra step is only necessary for the latitude if you are located in the southern hemisphere and/or the longitude if you are in the western hemisphere. If you need this extra block, plug the parameter that holds the GPS reading into the multiplication block first. In this example, we added the multiplier to the longitude values, so parameter b gets multiplied by -1 before it is fed into the subtraction block. When this is put into place, the code will look like this:

If you scroll to the end of your code, you will find another grey block, this time with an input. This is where you will inset the final output value so that it can be captured as the angle output parameter. Simply plug the data wire from the round block into the input of this grey block:

Parameter setup is now complete and the getAngle MyBlock is finished! When you add the MyBlock to a program, you will see the four inputs and a single output. When you hover your cursor over a parameter, its name will be displayed; keep this in mind, as it will help you avoid confusion:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.188.160