Saturday, September 30, 2017

21 September '17- Day 8- Intro to Data Structures, voltage regulators, servos

For todays lab we were introduced to voltage regulators and servos.  a voltage regulator works that it will supply a rated voltage given an input voltage is above that certain value.  In the case for our lab, we were given a 5 volt linear regulator to supply the servo we are using.  The servos them selves can run off the 5 volts from the arduino board but the 9v can provide the necessary current to run properly.  Once the servo is wired up the code for the arduino is fairly simple since there is a function already written in the arduino library to control the servo.  Part of the homework was to get the servo running and also attaching an arrow that points at the direction of movement sensed by the PIR sensor.
(here is a servo being used for project 1)

During lecture we talked about one dimensional arrays.  With arrays, we can declare a lot of the same data points without having to repeatedly declare variables for each point.  This technique cuts down on time and can store large amounts of data but can also make it difficult to debug a program.  In order to get a specific value that is declared in an array you must specify that element with a subscript, keeping in mind that the baseline for the order count starts at 0.  It is good practice to write a "define" at the beginning of the program to declare the number of elements in an array.

(examples in class of arrays)
For homework we were given our first project to come up with and include everything we've learned up to this point in the class.  My lab partner, Christina, and I decided on making a pet box and including some of the sensors to interact with the user.  More to come for Project 1...
(brain storming ideas for project 1)

19 September '17- Day 7- Random numbers and Recursion

Todays class involved a speaker and creating sound from the speakers.  Fairly simple lab but has tons of potential with the overall use of it.  The more tedious portion of this lab was to write certain songs in the library for pitches to be able to play the songs we'd like.

(wiring the speaker into the breadboard)
During lecture we began discussing generating random numbers and also recursion.  To generate a random number there is a function included in the standard C library called "srand(seed)".  This will generate random number.
Recursion is the ability for a function to call on itself.  A good example for this type of function would be factorials since computing a factorial would require that the first term is defined in order to solve for the next one.


(the different sensors learned up until today)




07 September '17-Day 4- Top down programming, logical and conditional statements


Beginning of class was spent working on Lab 4 which included wiring up the arduino board with a RGB LED and multiple switches.  The lecture in class went over the overall development for our algorithms and beginning every program with a top-down design.  Essentially we must look at the big picture and break down each step in the problem into steps for translating into language statements.  We also covered conditional expressions.  The conditional expressions include relational operators that can be used to compare two expressions.  A snap shot of a list of these operators is included below:

(these operators are used to compare expressions)
(examples using logical operators)
After the break we worked on more examples of condition statements as well as if/ else statements.  This allows us to execute a set of statements if a certain condition is true and if not then to continue on with a different statement.  Below are examples worked in class:

(writing out flowchart examples in the notes)



(hooking up a RGB LED to change colors for every time the button is pushed)










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)


14 September '17- Day 6- Functions and Modularity

Class began with Professor Mason checking our homework for integrating the TMP sensor with LEDs to indicate the ambient temperature and turning on a corresponding colored LED.  The next lab included a PIR sensor and wiring into our bread board to turn on LEDs when the sensor triggered by movement.  In class we went over programmer defined functions when trying to find the first 20 values of sin pi(x)/ pi(x).  From there we began talking about storage class and scope of variables.  Global variable and local variables define where they can be accessed to in a program.  local variables are defined within a function and can only be accessed within that function.  Global variables are defined outside the main function and can be accessed any time throughout the program by any function.  The last part of class we were given a problem to find the greater circle distance around the globe by being given two coordinate points.  Writing the program, we had to have user input two coordinates and generate the shortest distance from the two points.
(including a PIR sensor to light up LED)

(using coordinates to find angles between two vectors)

(having a TMP sensor indicated by LEDs; if temperature is hot the red led turns on, if temp is cold green led is on)


(screen shot for the greater distance program in class)

Tuesday, September 26, 2017

26 September '17- Project 1

Today during class we were given time to work on our projects from the following class meeting.  Also, we were introduced to a program called Fritzing.  This program allows us to create a visual schematic for how we wired up our projects.  The wiring schematic is good for cataloging our work in an easy to read format for anyone who would want to replicate the project we worked on.
Just to get started i created a simple schematic for wiring up a single LED using Fritzing.

(screen shot of the Fritzing program)
Working on the project was getting close to finishing up.  The pet box has come along way from the initial brainstorming.  Today we were able to retrofit the PIR sensor, the fur, and the RGB LEDs that are going to be on the front of the box.  Also the eyebrows for the pet box are mounted on to a couple VEX gears and attached to the servo.  Directly behind the servo is the PIR sensor pointed to the back of the box that will detect the "petting" movement on its fur.  Underneath the head of the box will be the action for the Arduino and soldered circuit board for all the resistors and LEDs to be switched on and off but a switch mounted to the front.

(the pet box with included RGBs and PIR)
(laser cutting out the pattern for the pet box)
(test fitting and gluing pieces together)
(assembling the head portion of the pet box)
(both boxes assembled partially until we instal electronics)
(assembling servo with VEX gears to move eyebrows) 
(testing the movement of the eyebrows)

(wiring up of Arduino and sensors to breadboard) 
More to come for the Pet Box...


Monday, September 11, 2017

05 September '17- Day 3 Linear Interpolation and Math functions in C,

At the beginning of class Professor Mason walked around the room to check on our blinking LED Knight Rider lights as well as the homework problems.  We also began the third lab which was to incorporate switches onto the bread board to control the intensity of the LEDs.  First, we began with a program to control the LED at different intensity levels for a delay of 100 milliseconds. Here is a screen shot of the code:
(Program for using loops and LED at different intensity levels)
We then modified the program so that the LED would change brightness levels at varying intensities. Here is the code:
(Program modification to dim LED at different intensity levels)
Afterwards, we were given the task to incorporate a button on the bread board to control when the LED is turned on.  Here is a screen shot of the code for the button:
(Program for having button operate the LED)
Once the time allotted for the lab had expired, we began lecture and were introduced to linear interpolation.  We were also introduced to new math functions for C and briefly talked about Salinity of salt water along with open jet engines.  We were given some problems to work out on whiteboards involving linear interpolation and how we can use it to our benefit with solving the freezing temperature of seawater using given two data points from a temperature vs. salinity graph.
(The given problem to solve by hand first then write in C)
After talking it over with my lab partner, we came up with the following:
(Scratch work for salinity problem above)
Solving using linear interpolation with two data points looks like this:
(Hand calculation)
(Program for calculating temperature of seawater using linear interpolation)
The next topic we discussed was the new math functions to use in C. The math functions allow us to input equations that contain logarithmic functions, exponents, compute absolute values, and square roots as well as being able to round up or round down to the nearest integer.  These new commands were useful when we came to calculating and writing an equation in C to compute the velocity and acceleration of an open-rotor jet engine. 
(Some hand work examples involving the new math functions and predicted answer)
(More examples of math functions)
The next task was to implement the new math functions into programs written for an open-rotor jet aircraft engine example and computing the new velocity and acceleration at any given time.



(Hand written calculations to compare the program to)

(Screen shot of the program and verification of calculated values)






31 August '17- Start with Arduino Lab

Day 2 began with starting the lab on the arduino and bread board.  We began class by gathering the necessary equipment and installing of the arduino IDE onto our computers.  From there, we started a very simple program to make a single LED blink from the "Tools" drop down menu while hooking up the wire to the arduino. Once we were able to get a single blinking LED we expanded the program to include 4 LEDs and ultimately have them turn on in sequence to match the knight rider car.
(Lab #1: mimicking the knight rider car KITT with LEDs)
Once lecture began Professor Mason discussed priority of operators.  Just like in math, certain operators take precedence in C.  The following list shows which operators and in what order they should be read:


After going over these operators we were given a task of writing an equation into C syntax so we can solve for the area of a trapezoid.  Writing the C syntax for this equation led us to solving a improper polynomial fraction.  A short cut to input the long polynomial was to input the numerator and denominator separately then having the program divide the numerator by the denominator.  This technique would yield a few steps as opposed to inputing everything on one line but had fewer chances for mistakes.  
Near the end of class we began writing a program to compute the height of both male and female skeletal structures from given length of the humerus and femurs.  The program looked like this:

( Program for height calculations )
For homework we were required to finish the KITT LEDs and to modify the forensics program for outputting converted values of height and also to write a program to compute the molecular weights of certain amino acids.   



Monday, September 4, 2017

29 August '17- Intro to programming

Day 1 began with familiarization of the programming language to be used with arduino.  C Language has been around since the 1970s and was developed by Dennis Ritchie at Bell Labs.  Going over the basic functions on the arduino as well as the most common syntax we'll be running into using C.  Using C we were able to write programs to solve for the distance formula using any distance between two point we entered, here is a screen shot of the code: After successfully writing the program and getting the correct value we modified to accept different x1, x2, y1, y2 values to makes sure the programs still works.

Points (-1,6) (2,4)


Points (1,0) (5,7)


Points (2,4) (2,4)
After adjusting the program to include different point values, we began discussion on using identifiers names and also the rules associated with choosing the right one.  Also being careful to use as much detail in the identifiers as to reference their use in the program.
After break we went on to talk about floating points and how to write in both scientific or exponential  notation.