Saturday, September 30, 2017

12 September '17-Day 5- Repetition Statements

At the beginning of class we had time to work on the Lab 5.  Lab 5 required us to hook up a potentiometer into the the breadboard and read out a value for POT using the serial monitor built into the Arduino IDE. once we had the pot hooked up we went on to tail about repetition statements.
(wiring up the potentiometer on the bread board)


(predicting the first three lines of code from degree-to-radian table)
These statements include while loops, do/while, and for loops.  While loops will continue to run until a condition becomes false.  Statements within this loop must modify variables that are used in the condition.   Do/while loops are similar except that the condition is tested at the end of the loop. This ensures the condition is tested at least once.  For /loop statements are based on the value of the variable that increases or decreases the same amount each time it loops.
(example of for loop statement; initial statement is k is equal to 5, second statement is k must be less than or equal to 83, and lastly each increment of k is added with 4)
Afterwards we were introduced to break and continue statements.  break is used to exit out of a loop statement and continue is the opposite and used to skip any remaining statements and continue to the next portion of the loop.
For the homework assignment we were tasked to write a program for the interaction of two waves.  First we must come up with a problem statement, secondly we must describe the input and output values, and lastly was to calculate by hand the data given to us in order to check our answers from the program.
(calculations using the given equations for each wave; use these number to verify program)


No comments:

Post a Comment