Thursday, March 30, 2017

Day 7

Day 7


Our first project. Groups with Maria and I.


The design here is to get the sound to work by using a photocell and the lights by using a motion sensor.


Wires are very jungles here, oh no.


Button here controls the lights and sound.


Pictures for the fritzing.


More pictures for fritzing.


Fritzing of the final project.

Day 6

Day 6


The new model, implementing the use of a thermistor to change the lights of the LED for sensing if the temperature is hot (red), cold (blue), or just right (green).


The coldness of the water bottle cools the thermister and changes the light indicator to blue.

video illustrating the effect mentioned above.



Heating the thermistor using body heat from my fingers changes the light indicator to red.

Video illustrating the effect. if it ever works on here.



Practice code for attaining formal values from the actual.


More exercises.


Program for computed the distance between New York and London including the curvature of the earth using all dimensions from the earth's origin coordinates.

Day 5

Day 5


The command a computer will give for the number imputed to the left.


Practice using floor.


The superposition wave calculator. Adds amplitudes of two waves to get a new wave.

A fun competition that I participated during the weekend for the builders challenge, the objective to transport an egg whole to the marked area.,, sadly we did not win ;( sad face, our SHPE was sunk.


Moments before the sinking.


Team SHPE!
Representing the Society of Hispanic Professional Engineers.

Day 4

Day 4


Implementing two LED's using two buttons.


The desired effect, the Po-Po lights lol.


Now using an RGB LED. each wire here was color coded so that the red and green LED pins can be easily verified.


Practicing using and (&&) statements.


Here we practice using bam (!,not) and or (||) statements.


Box analysis for figuring out what the code will do at each of the scenarios.


Here there are four scenarios at which the code can go through.


The LED lights up red here. The golf ball is used to make the light look bigger but it seems to make it dimmer too.


The LED here lights green.


The LED lights blue.


Now by combining red and blue in the RGB digital write commands, we see purple.


3 other codes with their own scenarios.


This code seems to have many branches within branches.


Switch Crank's case rank code.

Homework

1. If a1 is true and a2 is false, then which of the following expressions are true?

(a) a1 && a2 False
(b) a1 || a2 True
(c) !(a1 || a2) True
(d) !a1 && a2 True

2. Give the value of, a, after the following set of statements, is executed.

int a = 750;
...
if (a>0)
if (a >= 1000)
a = 0;
else
if (a < 500)
a *= 2;
else
a *= 10;
else
a += 3;

3. Modify your RGB night light as follows: 

(a) Modify your program to add the colors of Teal, Orange, and White.

(b) Implement a switch statement to control the color mode.

(c) Add additional buttons to independently control each of the three colors.

(d) Add a blink mode to have your color flash on and off.



Day 3

Day 3


Using the formula above to find f(b).


f(b) is 109.92


Formula moved around to find b instead.


A three-step method for finding the freezing temperature between two points.


Practicing using floors, ceil, and fabs commands.


Another three-step method for planning the code for finding the acceleration and velocity from the given time input.

Homework

Saturday, March 4, 2017

Day 2

Day 2


On day 2 lab was to build an LED circuit and get it to function like the K.I.T.T. car from the Knight Rider TV series. The materials used are; breadboard, 4 resistors, 6 wires, 4 LED's, an arduino, and a computer.


This is the arduino used from day 1 that will be used to program our circuit.


The C syntax for calculating energy of an object in motion through a ramp.


The C syntax for centripetal acceleration, potential energy, and change in potential energy from left to right.


The completed LED circuit. Here the red wire is the one that is responsible for bringing in power to the circuit, also is the grounded wire, and the resistors are there so that the circuit doesn't have too much current running through it, which could destroy the circuit board.


Practicing increment and decrement operators.


Practicing the printf command to return a value of printable characters.


Exercise to determine the height of a person using forensics based on their femur or humerus heights.


The circuit here was programmed to turn on from the red light to the yellow light and come back to red, to mimic the K.I.T.T car's effect.


Blue light next in series.


Green light actuates after the blue light.


Yellow light activates last in the series, where it will then go back to the red light.


K.I.T.T. Car from the Knight Rider.

Homework
#1 Program a function to convert meters to miles.

/*--------------------------------------------------------*/
/* Program Chapter1_1                                     */
/*                                                        */
/* this program computes the                              */
/* distance in meters to miles.                           */
#include <stdio.h>
#include <math.h>
int main(void)
{
    /* Declare and initialize variables. */
    double x1=1000, miles;
    /* compute miles. */
    miles=x1/(1609);
    /* Print distance. */
    printf ("The distance in miles is"
    "%5.2f\n",miles);
    /* Exit program. */
    return 0;
}
/*---------------------------------------------------------*/

#2 Program a function that converts Celsius to Rankine.

/*--------------------------------------------------------*/
/* Program Chapter1_2                                     */
/*                                                        */
/* this program computes the                              */
/* degrees in Rankine.                                    */
#include <stdio.h>
#include <math.h>
int main(void)
{
    /* Declare and initialize variables. */
    double x1=100, Rankine;
    /* compute Rankine. */
    Rankine=(x1+273)*(5/9);
    /* Print Rankine. */
    printf ("The degrees in Rankine is %5.2f\n",Rankine);
    /* Exit program. */
    return 0;
}
/*---------------------------------------------------------*/

#3 Program a function that calculates the area of an ellipse.

/*--------------------------------------------------------*/
/* Program Chapter1_3                                     */
/*                                                        */
/* this program computes the                              */
/* area of an ellipse.                                    */
#include <stdio.h>
#include <math.h>
int main(void)
{
    /* Declare and initialize variables. */
    double x1=1, y1=2, Area;
    /* compute Area. */
    Area=(x1*y1)*(22/7);
    /* Print Area. */
    printf ("The area of the ellipse is"
    "%5.2f\n",Area);
    /* Exit program. */
    return 0;
}
/*---------------------------------------------------------*/

#4 Program a function that calculates the area of a sector of a circle.

/*--------------------------------------------------------*/
/* Program Chapter1_4                                     */
/*                                                        */
/* this program computes the                              */
/* area of a sector of a circle.                          */
#include <stdio.h>
#include <math.h>
int main(void)
{
    /* Declare and initialize variables. */
    double x1=10, d1=60, Area;
    /* compute Area. */
    Area=(d1*2*22/7*x1*x1)/360;
    /* Print Area. */
    printf ("The area of the sector is "
    "%5.2f\n",Area);
    /* Exit program. */
    return 0;
}
/*---------------------------------------------------------*/

#5 Program a function that gives the height of a man or woman based on humerus and femur length.

/*-----------------------------------------------------*/
/* Program chapter1_5                                  */
/*                                                     */
/* this program computes the                           */
/* hight of the human                                  */
#include<stdio.h>
#include<math.h>

int main()
{
    /* Declare of variables. */
    double Female_height_femur, Female_height_humorus, Male_height_femur, Male_height_humorus, length;
    /* compute the height. */
    scanf("%lf",&length);
    Female_height_femur=length*1.94+28.7;
    Female_height_humorus=length*2.8+28.2;
    Male_height_femur=length*1.94+32;
    Male_height_humorus=length*2.9+27.9;
    /* Print height. */
printf("%5.2f %5.2f %5.2f %5.2f\n", Female_height_femur, Female_height_humorus, Male_height_femur, Male_height_humorus);
/* Exit program. */
return 0;
}
/*-----------------------------------------------------*/

#6 Program the Arduino to cause the LED's to flicker like the K.I.T.T. car.

void setup() {
pinMode(10,OUTPUT); //Initialize Pin
pinMode(8,OUTPUT); //Initialize Pin
pinMode(6,OUTPUT); //Initialize Pin
pinMode(4,OUTPUT); //Initialize Pin
}
void loop() {
digitalWrite(10,HIGH); //Set the LED On
delay(100); //Wait for 1000 ms
digitalWrite(10,LOW); //Set the LED Off
delay(10); //Wait for 1 second

digitalWrite(8,HIGH); //Set the LED On
delay(100); //Wait for 1000 ms
digitalWrite(8,LOW); //Set the LED Off
delay(10); //Wait for 1 second

digitalWrite(6,HIGH); //Set the LED On
delay(100); //Wait for 1000 ms
digitalWrite(6,LOW); //Set the LED Off
delay(10); //Wait for 1 second

digitalWrite(4,HIGH); //Set the LED On
delay(100); //Wait for 1000 ms
digitalWrite(4,LOW); //Set the LED Off
delay(10); //Wait for 1 second

digitalWrite(6,HIGH); //Set the LED On
delay(100); //Wait for 1000 ms
digitalWrite(6,LOW); //Set the LED Off
delay(10); //Wait for 1 second

digitalWrite(8,HIGH); //Set the LED On
delay(100); //Wait for 1000 ms
digitalWrite(8,LOW); //Set the LED Off
delay(10); //Wait for 1 second
}

#7

/*-----------------------------------------------------*/
/* Program chapter1_5                                  */
/*                                                     */
/* this program computes the                           */
/* hight of the human                                  */
#include<stdio.h>
#include<math.h>

int main() 
{
    /* Declare of variables. */
    float Female_height_femur, Female_height_humerus, Male_height_femur, Male_height_humerus,
    Female_femur_feet, Female_humerus_feet, Male_femur_feet, Male_humerus_feet, humerus_feet, femur_feet,
    femur_inches, humerus_inches;
    /* compute the height. */
    scanf("%f",&femur_feet);
    scanf("%f",&humerus_feet);
    femur_inches=femur_feet*12;
    humerus_inches=humerus_feet*12;
    Female_height_femur=femur_inches*1.94+28.7;
    Female_height_humerus=humerus_inches*2.8+28.2;
    Male_height_femur=femur_inches*1.94+32;
    Male_height_humerus=humerus_inches*2.9+27.9;
    Female_femur_feet=Female_height_femur/12;
    Female_humerus_feet=Female_height_humerus/12;
    Male_femur_feet=Male_height_femur/12;
    Male_humerus_feet=Male_height_humerus/12;
    /* Print height. */
printf("Female height by femer size - " "%5.2f feet. \n", Female_femur_feet);
printf("Female height by humerus size - " "%5.2f feet. \n",Female_humerus_feet);
printf("Male height by femer size - " "%5.2f feet. \n", Male_femur_feet);
printf("Male height by humerus size - " "%5.2f feet. \n", Male_humerus_feet);
/* Exit program. */
return 0;
}
/*-----------------------------------------------------*/

#8

/*-----------------------------------------------------*/
/* Program chapter1_5                                  */
/*                                                     */
/* this program computes the                           */
/* hight of the human                                  */
#include<stdio.h>
#include<math.h>

int main() 
{
    /* Declare of variables. */
    float Female_height_femur, Female_height_humerus, Male_height_femur, Male_height_humerus,
    Female_femur_centimeters, Female_humerus_centimeters, Male_femur_centimeters, Male_humerus_centimeters,
    humerus_centimeters, femur_centimeters, femur_inches, humerus_inches;
    /* compute the height. */
    scanf("%f",&femur_centimeters);
    scanf("%f",&humerus_centimeters);
    femur_inches=femur_centimeters/2.54;
    humerus_inches=humerus_centimeters/2.54;
    Female_height_femur=femur_inches*1.94+28.7;
    Female_height_humerus=humerus_inches*2.8+28.2;
    Male_height_femur=femur_inches*1.94+32;
    Male_height_humerus=humerus_inches*2.9+27.9;
    Female_femur_centimeters=Female_height_femur*2.54;
    Female_humerus_centimeters=Female_height_humerus*2.54;
    Male_femur_centimeters=Male_height_femur*2.54;
    Male_humerus_centimeters=Male_height_humerus*2.54;
    /* Print height. */
printf("Female height by femer size - " "%5.2f centimeters. \n", Female_femur_centimeters);
printf("Female height by humerus size - " "%5.2f centimeters. \n",Female_humerus_centimeters);
printf("Male height by femer size - " "%5.2f centimeters. \n", Male_femur_centimeters);
printf("Male height by humerus size - " "%5.2f centimeters. \n", Male_humerus_centimeters);
/* Exit program. */
return 0;
}
/*-----------------------------------------------------*/

#8

/*-----------------------------------------------------*/
/* Program chapter1_6                                  */
/*                                                     */
/* this program computes the                           */
/* molecular weight of molecules                       */
#include<stdio.h>
#include<math.h>

int main() 
{
    /* Declare of variables. */
    float Oxygen, Carbon, Nitrogen, Sulfur, Hydrogen, glycine, glutamic, glutamine, amino_acid;
    /* compute the weight. */
    Oxygen=15.9994, Carbon=12.011, Nitrogen=14.00674, Sulfur=32.066, Hydrogen=1.00794;
     glycine=2*Oxygen+2*Carbon+1*Nitrogen+0*Sulfur+5*Hydrogen;
     /* Print weight. */
     printf("The molecular weight of glycine is ""%5.2f AMU. \n",glycine);
     /* Exit program. */
return 0;
}
/*-----------------------------------------------------*/

#9

/*-----------------------------------------------------*/
/* Program chapter1_6                                  */
/*                                                     */
/* this program computes the                           */
/* molecular weight of molecules                       */
#include<stdio.h>
#include<math.h>

int main() 
{
    /* Declare of variables. */
    float Oxygen, Carbon, Nitrogen, Sulfur, Hydrogen, number_of_oxygen_atoms, number_of_carbon_atoms,
    number_of_nitrogen_atoms, number_of_sulfur_atoms, number_of_hydrogen_atoms,
    glycine, glutamic, glutamine, amino_acid;
    /* compute the weight. */
    scanf("%f",&number_of_oxygen_atoms);
    scanf("%f",&number_of_carbon_atoms);
    scanf("%f",&number_of_nitrogen_atoms);
    scanf("%f",&number_of_sulfur_atoms);
    scanf("%f",&number_of_hydrogen_atoms);
    Oxygen=15.9994, Carbon=12.011, Nitrogen=14.00674, Sulfur=32.066, Hydrogen=1.00794;
    amino_acid=number_of_oxygen_atoms*Oxygen+number_of_carbon_atoms*Carbon+
    number_of_nitrogen_atoms*Nitrogen+number_of_sulfur_atoms*Sulfur+number_of_hydrogen_atoms*Hydrogen;
     /* Print weight. */
     printf("The molecular weight of this amino acid is ""%5.2f g/mol. \n",amino_acid);
     /* Exit program. */
return 0;
}
/*-----------------------------------------------------*/

#10

/*-----------------------------------------------------*/
/* Program chapter1_6                                  */
/*                                                     */
/* this program computes the                           */
/* molecular weight of molecules                       */
#include<stdio.h>
#include<math.h>

int main() 
{
    /* Declare of variables. */
    float Oxygen, Carbon, Nitrogen, Sulfur, Hydrogen, number_of_oxygen_atoms, number_of_carbon_atoms,
    number_of_nitrogen_atoms, number_of_sulfur_atoms, number_of_hydrogen_atoms,
    glycine, glutamic, glutamine, amino_acid, Average_molecular_weight;
    /* compute the weight. */
    scanf("%f",&number_of_oxygen_atoms);
    scanf("%f",&number_of_carbon_atoms);
    scanf("%f",&number_of_nitrogen_atoms);
    scanf("%f",&number_of_sulfur_atoms);
    scanf("%f",&number_of_hydrogen_atoms);
    Oxygen=15.9994, Carbon=12.011, Nitrogen=14.00674, Sulfur=32.066, Hydrogen=1.00794;
    amino_acid=number_of_oxygen_atoms*Oxygen+number_of_carbon_atoms*Carbon+
    number_of_nitrogen_atoms*Nitrogen+number_of_sulfur_atoms*Sulfur+number_of_hydrogen_atoms*Hydrogen;
    Average_molecular_weight=amino_acid/(number_of_oxygen_atoms+number_of_carbon_atoms+
    number_of_nitrogen_atoms+number_of_sulfur_atoms+number_of_hydrogen_atoms);
     /* Print weight. */
     printf("The molecular weight of this amino acid is ""%5.2f g/mol#ofatoms. \n",Average_molecular_weight);
     /* Exit program. */
return 0;
}
/*-----------------------------------------------------*/

#11

/*-----------------------------------------------------*/
/* Program chapter1_6                                  */
/*                                                     */
/* this program computes the                           */
/* molecular weight of molecules                       */
#include<stdio.h>
#include<math.h>

int main() 
{
    /* Declare of variables. */
    float Oxygen, Carbon, Nitrogen, Sulfur, Hydrogen, number_of_oxygen_atoms, number_of_carbon_atoms,
    number_of_nitrogen_atoms, number_of_sulfur_atoms, number_of_hydrogen_atoms,
    glycine, glutamic, glutamine, amino_acid, Average_molecular_weight;
    /* compute the weight. */
    scanf("%f",&number_of_oxygen_atoms);
    scanf("%f",&number_of_carbon_atoms);
    scanf("%f",&number_of_nitrogen_atoms);
    scanf("%f",&number_of_sulfur_atoms);
    scanf("%f",&number_of_hydrogen_atoms);
    Oxygen=15.9994, Carbon=12.011, Nitrogen=14.00674, Sulfur=32.066, Hydrogen=1.00794;
    amino_acid=number_of_oxygen_atoms*Oxygen+number_of_carbon_atoms*Carbon+
    number_of_nitrogen_atoms*Nitrogen+number_of_sulfur_atoms*Sulfur+number_of_hydrogen_atoms*Hydrogen;
    Average_molecular_weight=amino_acid/(number_of_oxygen_atoms+number_of_carbon_atoms+
    number_of_nitrogen_atoms+number_of_sulfur_atoms+number_of_hydrogen_atoms);
     /* Print weight. */
     printf("The average molecular weight of this amino acid is ""%5.2f g/mol#ofatoms. \n",Average_molecular_weight);
     /* Exit program. */
return 0;
}
/*-----------------------------------------------------*/