Wednesday, April 5, 2017

Day 5

 Topics

  • Analog Sensor control
  • Using the for loop
  • Programming Homework
Analog Sensor control


   We started off with a simple led control with the pot. Once that was done, We used out new tool, "analogRead/Write", to interact with sensors on the board. In this particular sketch, We read from a temperature sensor and passed those values to an RGB LED. In class, we tested the sensor with ice and pitched the sensor between our fingers to warm the sensor up. 

Programming Homework

My first program is fairly straightforward. I first started with my outline and hand example to guide me. I used freemat to check what I was doing.
Then I wrote my program and used the value in the for loop to determine the value of my feet per second. It was more compact that way. It gave me exactly what I wanted. 



   For the second programming project I had to reread the instructions a few times to figure out all the steps I would need to get done. 





The first modification of this program had me also output the min trough of the cycle. I defined a new variable, "Min height", and added another while loop similar to the one I created to find the max height. It makes sense for the min and max values to be the same because both functions are sine without any phase shift. 



Next, we were more concerned with the exact time of the wave and being able to examine any point in the domain. For this, I could get rid of the the scan and print functions I had at the start. I can also get rid of calculating the wavelengths and use the values from previous itterations. It's much simpler program. And my test values match the hand calculations I made to check that it works. 

After this, We had to modify the program to change the amounts of points we wanted to check in order to get the min and max values. This really shouldn't change the actually values to much. We may add more digits of accuracy but I suspect the original numbers will be close to my new values. 





I realize now that giving the ability to define the number of test points does change the values when we choose to few points to have an accurate figure. Barring that, my prediction was correct as to getting the same value as we had gotten. 

   Then I had o change my program to allow for phase shifts, as test out some phase shifts. I choose to shift it by multiples of pi because that seems familiar as opposed to a dimensionless radian value.  when I began experimenting with values I realized that a shift of any integer value of pi will not change my min and max in any way. Shifting around half pi had one of the more dramatic effects. 


No comments:

Post a Comment