Tuesday, April 18, 2017

Day 6

Topics

  • Modulating programs
  • Programming and calling a modular function
  • Using a photoresistor and a button

Programming

   The first step was to make a program with a the defined prototype statement.



   I had to also declare the prototype in order to be able to use the function.

   Next, I was to use the function written while calculating. I looked at the function that was there and realized I would be smart to take out rho and use it as a definition instead of a local variable in the distance function.



   I realize now I would be best to tear the entire thing apart and have each step as a function. I would also need to define some new variables. At least, I had designed this program, I would use this way.



   While I would like to do this, I think I will instead convert the original program and use that. I don't need to phi or theta values anywhere else that in the function.



   With this declaration as well as the function for calculating the angle between two points, I can then return the values I want simply.




   To add the ability for the user to input the cardinal direction, I first added Two arguments to the conversion function as well declaring a new set of variables to the main.


   I actually realized that I didn't need to declare the character as an array because it only has the one element. I made that change and then updated by function.




   If I am to add the ability to change the West-East direction as well then I had best pull out the whole phi phi theta parts. After all of the conversions are done then I put the actual conversion. This made the program a little more readable and smaller. Of course, this same structure is repeated for both points.






That combines the entire program modifications into a set of functions.

No comments:

Post a Comment