Wednesday, March 15, 2017

Day 3

Topics

  • Using pulldown resistors
  • programming
Lab
This particular sketch has the effect of increasing the delay in ever step of the loop until it increments for 10 cycles then it starts over.


It took a little while but i talked my way through the working of the resistor in the circuit. Without the resistor the only current flows when we have the button pressed. This leaves the the possibility of a signal from sourrounding elements. We need the resistor bridge to so there is always a path for a current to ground. The resistor has more resistance than the button we choose so it leaves a lower resistance path for current when we have a button pressed.





Homework Notes


 I have to get a computer working because I forgot to send over my finished programs for the amino acid assignment and ended up trying to write the entire things again in the time between my classes. It was a valiant effort, overall a screwup. Fortunately I should have this worked out by thusrday. All i need now is to get a network card because the wifi is dodgie.



Lecture
Remember! Any curve, when properly constrained is an example of a linear curve. ALWAYS FOCUS ON WHERE YOU'RE CONSTRAINTS ARE.




Programming



   This was the first attempt I made at doing the programming homework. I put in a little check to make sure the number is a positive number.


   This worked after some slight debugging. I had msspelled some printf and used a backslash where I should have used a forward slash.



The next step was to write a function that computed the same thing but with base 8. This was a change of one number and that's it.






Thursday, March 2, 2017

Day 2

Topics

  • Using the Arduino to send currents
  • using math in C
  • Homework problems
    • Estimating height from bone lengths
    • molecular weights and amino acids

Led board

In our first delve into connecting the Arduino with the outside world, we had to set up a simple circuit to light an LED.
After that, we wanted to set up a string of 5 bulbs and have the light up, visa ve Nightrider. My particular board didn't have a runner across the length so I had to come up with an alternative method to supply power. I ended up running power across the top row and jumping to other rows.
 once it was all connected it looked like this 



Lecture

We started the lecturing by going over the labs we had completed. My code worked just fine but I have to be more specific by my variable names.
There is no way to tell what I was talking about if I wanted to go back and change this later. Plus, anything more complicated will immediately have be forgetting such generic symbols. I will work on this for my next lab.

After that, learned how to define variable we want. I can decide my useful constants for the program and not have it close to hand through my entire program.

Then we learned about priority on operators, It was similar to order of operations.  One to remember is making the code readable by formatting, 
Something like this makes it obvious what's happening. Also, when we have longer calculations it's smart to break it into steps, Not only does this make the coding a little easier; troubleshooting is naturally structured to proceed in bite-sized bits. 


We also need to watch out for overflow and underflow. This hammers home the idea of knowing how you are assigning space in the memory. 

we also did some practice with incrementing and decrementing variables. once thing to remember is that when you uses the ++ or -- operators as suffixes then it will not actually apply until after other operations have been completed. 

We also learned about control strings and conversion strings. As far as I can tell, control strings will be used to preform an action and is inside quotations. 
That \n tells the program to put in a line break.

convertion strings are used to tell the computer what sort of value it should be using. This also run the risk of being misused and then screwing the program. The example we used was casting %i as %c and getting back an Ascii equivelant for an answer. 2 + 2 = d
The ability to take in inputs also came up today. 
It's used like printf. First you have to use a conversion string to prompt the computer what is about to be scanned, The &year tells the computer where to house the scanned information. This is a possible problem, For instance, trying to store a float in an int.. Also, don't forget those "" around the conversion.   

Homework

Started by using the process we learned during class.


//-------------------------------------------This is the original problem---------------------------
#include<stdio.h>
#include<math.h>

int main()
{
float femur, humerus, MheightFemur, MheightHumor, FheightFemur, FheightHumor; 
//-----------------------------------this takes in my heights
scanf("%f, %f", &femur,&humerus);

//-------------------this is where I do my calculations     

FheightFemur = femur * 1.94 + 28.7;
MheightFemur = femur * 1.88 +32; 
FheightHumor = humerus * 2.8 + 28.2;
MheightHumor = humerus * 2.9 + 27.9;
//-------------------------this will print out my ranges


printf("Based on femur length this is either a %.2f inch female or a %.2f inch male\n", FheightFemur,MheightFemur);
printf("Based on humerus length this is either a %.2f inch female or a %.2f inch male", FheightHumor,MheightHumor);

return 0;
}


//-------------------------------This converts inches input to foot output-----------------------------------------

#include<stdio.h>
#include<math.h>

int main()
{
float femur, humerus, MheightFemur, MheightHumor, FheightFemur, FheightHumor; 
//-----------------------------------this takes in my heights
scanf("%f, %f", &femur,&humerus);

//-------------------this is where I do my calculations     

FheightFemur = femur * 1.94 + 28.7;
FheightFemur = FheightFemur /12;
MheightFemur = femur * 1.88 +32; 
MheightFemur = MheightFemur / 12;
FheightHumor = humerus * 2.8 + 28.2;
FheightHumor = FheightHumor / 12;
MheightHumor = humerus * 2.9 + 27.9;
MheightHumor = MheightHumor / 12;
//-------------------------this will print out my ranges


printf("Based on femur length this is either a %.2f foot female or a %.2f foot male\n", FheightFemur,MheightFemur);
printf("Based on humerus length this is either a %.2f foot female or a %.2f foot male", FheightHumor,MheightHumor);

return 0;
}

//-------------------------------This takes in feet and outputs feet-------------------------------------------------

#include<stdio.h>
#include<math.h>

int main()
{
float femur, humerus, MheightFemur, MheightHumor, FheightFemur, FheightHumor; 
//-----------------------------------this takes in my heights
printf("input the size of the femur and then humerous, in feet please\n");
scanf("%f, %f", &femur,&humerus);

//-------------------this is where I do my calculations     

femur = femur * 12;
humerus = humerus * 12;
FheightFemur = femur * 1.94 + 28.7;
FheightFemur = FheightFemur /12;
MheightFemur = femur * 1.88 +32; 
MheightFemur = MheightFemur / 12;
FheightHumor = humerus * 2.8 + 28.2;
FheightHumor = FheightHumor / 12;
MheightHumor = humerus * 2.9 + 27.9;
MheightHumor = MheightHumor / 12;

//-------------------------this will print out my ranges


printf("Based on femur length this is either a %.2f foot female or a %.2f foot male\n", FheightFemur,MheightFemur);
printf("Based on humerus length this is either a %.2f foot female or a %.2f foot male", FheightHumor,MheightHumor);

return 0;
}

//-----------------------------------------------This gives out both feet and inches ----------------

#include<stdio.h>
#include<math.h>

int main()
{
float femur, humerus, MaleFemurInches, MaleHumerInches, FemaleFemurInches, FemaleHumerInches, MaleFemurFeet, FemaleFemurFeet, MaleHumerFeet, FemaleHumerFeet;


//-----------------------------------this takes in my heights
printf("input the size of the femur and then humerous, in inches please\n");
scanf("%f, %f", &femur,&humerus);


//---------------------------------this is where I do my calculations  

FemaleFemurInches = femur * 1.94 + 28.7;
MaleFemurInches = femur * 1.88 +32;
FemaleHumerInches = humerus * 2.8 + 28.2;
MaleHumerInches = humerus * 2.9 + 27.9;

//--------------------------------------------This is where I assign feet and inches variables

MaleFemurFeet = MaleFemurInches / 12;
FemaleFemurFeet = FemaleFemurInches / 12;
MaleHumerFeet = MaleHumerInches / 12;
FemaleHumerFeet = FemaleHumerInches / 12;

//-------------------------------this will print out my ranges


printf("First, female heights by femur legth. \nYou're looking at %.1f feet or %.1f inches tall.\n",FemaleFemurFeet, FemaleFemurInches);
printf("Next, male heights by femur legth.\nThis is %.1f feet or %.1f inches tall.\n",MaleFemurFeet, MaleFemurInches);
printf("Humerus time! \nThis is could be a female of %.1f feet or %.1f inches", FemaleHumerFeet, FemaleHumerInches);
printf("\nThis is possibly a male of %.1f feet or %.1f inches", MaleHumerFeet, MaleHumerInches);

return 0;
}

//-----------------------------------------------This program takes in cm and gives out cm values---------------

#include<stdio.h>
#include<math.h>

int main()
{
  float femur, humerus, MheightFemur, MheightHumor, FheightFemur, FheightHumor;
//-----------------------------------this takes in my heights
printf("please enter the femur and humerus length in centimeters, if you would.\n");
scanf("%f, %f", &femur,&humerus);



//----------------------------------I convert from centimeters to inches
femur =  femur / 2.54;
humerus = humerus / 2.54;

//-------------------this is where I do my calculations  
FheightFemur = femur * 1.94 + 28.7;
MheightFemur = femur * 1.88 +32;
FheightHumor = humerus * 2.8 + 28.2;
MheightHumor = humerus * 2.9 + 27.9;


//-----------------------------------------------I convert back to centimeters
FheightFemur = FheightFemur * 2.54;
MheightFemur = MheightFemur * 2.54;
FheightHumor = FheightHumor * 2.54;
MheightHumor = MheightHumor * 2.54;

//-------------------------this will print out my ranges



printf("Based on femur length this is either a %.2f centimeter female or a %.2f centimeter male\n", FheightFemur,MheightFemur);
printf("Based on humerus length this is either a %.2f centimeter female or a %.2f centimeters male", FheightHumor,MheightHumor);

return 0;
}


//--------------------------------------This program calculated molecular weights

#include<stdio.h>
#include<math.h>
//---------------------------------I defined my atomic weights

#define oxygen 15.9994
#define carbon 12.011
#define nitrogen 14.00674
#define suler 32.066
#define hydrogen 1.00794

int main()
{
//----------------------------------------I add my atomic weights

float glycine, glutamic, glutamine;
glycine = 2*oxygen + 2*carbon + nitrogen + 5*nitrogen;
glutamic = 4*oxygen + carbon*5 + nitrogen + hydrogen*8;
glutamine = oxygen*3 + carbon*5 + nitrogen*2 + hydrogen*10;
//--------------------------------------------------I print out the weights

printf("glycine has a moleculare weight of %9.7f \n", glycine);
printf("Glutamic has a molecular weight of %9.7f \n", glutamic);
printf("glutamine has a molecular weight of %9.7f \n", glutamine);
return 0;

}