Thursday, June 15, 2017

Day 23

Topics

  • cyclone and hurricanes
  • C++ classes
Cyclones and Hurricanes

   The first step was to simply count the number of types of storms in the data and print them out to the screen. I did this in a few lines of code, using a for loop.




   The second part of the program was to print when there are multiple max wind types. I placed the printing section into a for loops and then compared the maxk value to print for each occurance of the at max number.






   The third part of the program was to print a warning if there were winds from the cardinal directions in the data. I had to first change some of the numbers in the file and also check the values in the categories.



   The forth part of the homework was to print out a grid of symbols corresponding to the right direction. I first filled a new array and then printed out that grid. 





   I was able to recast most of it but, for some reason, the grid wasn't entirely correct. I can't really figure out why. 






C++ Classes

   The first step was to just setup a class. I setup the class header file.



I also wrote  a program to use this class. 




   I am doing something wrong because whenever I try to run the program I am redirected to the header file.



    I keep changing the way I declare the array of strings. I can't call is a character array because these are more than one set of characters. It's more like an array of character arrays. I will have to work on this more tomorrow. I ended up having to make an array of strings which also meant I had to include the sting library.



   I had a problem actually getting the array to work unless I individually added the elements as I wanted them to be. I did this by first declaring I wanted an array and then making a constructor to fill it.





   I was still having this problem with my function so I added these prints to know which part was working. I know that constructor works.



   The next thing I tried was to set the date. It wouldn't compile. Looking back at my function, I realize it doesn't make and sense. I was using cin to set the values but still feeding it arguments.



   Even after I removed the variables it was still not working. What I wonder is if each object in a class has a variable unique to it.




Wednesday, June 14, 2017

Day 22

Topics
  • Scanning I2C Devices
  • Intro to C++

Scanning I2C devices

   The project could involve multiple I2C devies so it ain't no good to have the same adress for them. I setup the devices I would be using. Then, I started scanning. First was the EEProm. 






  Next I scanned the load sensor. It wasn't an I2C device because nothing showed up. Moving onto the IMU board and I found two addresses for this device. 




   I will have to also scan the SD card because I believe that follows the same I2C routine. 


   I looked it up. SD cards use a different routine, SPI. This is good. I shouldn't have any any conflict between the devices I will use.

EEProm: 0x50
IMU : 0x68; 0x76



Introduction to C++

   The first modification was to watch the keyboard and wait for inputs.  I made, what I consider, a simple solution. What I got back was a cascade of errors.





   Because they looked to be something other than a syntax error, I tried running the running the program on two different online compilers. These gave me even more errors. Even when I ran the program right of the book. first image is Jdoodle; second is C++shell. 







   I changed one thing, the "int' declaration of the "i" in my for loop and most of the errors were resolved. Not sure why.













   I tried doing the same thing with a while loop. This gave more errors than the for loop.





   I used the program introduced in class today; that allowed me to do what needed doing. I ended up doing two ways to input the values because my original cin had an endl at the end and I didn't realize that was the problem. Pointers work just fine here. I tested what I had by putting in the original values. 





   Then I was to put the known values  into a file and read them out. I was getting weird values and then I decided to print out the values because I wasn't getting the right values.





   I was able to figure out the problem. I left out some brackets and as well as not having the correct value for ending the for loop.



  Next, I was to compute the minimum distance between the hands. I made a new function to call at the end. I had to change some values in order for the function to work because two of the numbers were the same. 





   I then had to get the function to print out which location had the know distance. I did this by adding one more variable that was changed whenever the minimum distance if loop runs.




   The next part was the find multiple instances of the same min value. I used the same structure while and compared those values to the min value I find before hand. Then I simple scroll through the values and array and find what I need.




Day 24

Topics

Complex Roots

   The first step was step was to the get program working in the case of a double root. This part was a matter of fixing a few bugs from the program and making sure we had the header file in the  correct folder.  There was also a problem with the include. Instead of using the < someting.h> we had to use #include "File.h". The quotes seem to be important to the header files we create and place in the folder. I imagine it directs the compiler of where to look for the header. 





   Next, we were supposed to set up a structure to deal with the different kind of roots (real, double, complex). I did this by using a series of else if statements that check the value of discriminent. if the roots aren't real and distinct or complex then we must have a double root. 









   I tested the values and they all worked out alright. 







   Getting two decimal points of precision meant first fixing the decimal point and then asking for 2 point of precision. You can see the levels of precision in the above code. Full disclosure, I wrote the blog after finishing the lab. 





Tuesday, June 6, 2017

Day 13

Topics

  • LCD Screen
   The first step thing we needed to do was to setup the mapping of the buttons. I can use these values it trigger different actions on the screen. Setting up an interval of values also accounts for any voltages that aren't exactly what I expect.  



I have the screen print what buttons I want the user to press in order to get the values.



   Using the same structure in the homework program will allow me to print out values when I press the buttons I want. I also pause for 2.5 seconds before resetting my display message and allowing the user to check the other values. One problem I had was when I didn't include the wire.read function in the if statement I couldn't actually display the values. This also triggers the check at the time you press the button. 



  • Pointer Value homework
   The programming homework was simple and I am still a little uncertain on how we will be using these pointers. I know that mason says they are useful in navigating arrays. I imagine that we will want to use this sort of thing when we are