Skip to main content

Day 1: Introduction to Programming

Summary
We first learned about the different types of applications of programming to various engineering fields. Then we went over the types of computer languages, which included, machine, assembly, and high-level languages. C and C++, the languages used in this course, are both high-level languages. We were introduced to the engineering problem solving methodology, which is as follows:

  1. Problem statement
  2. Input/output description
  3. Hand example
  4. Algorithm development
  5. Test solution
We then did an activity which utilized this. We got together in groups to perform steps 1-3 in trying to find the distance between two points, then tested this on the computer. 

After that, we learned about constants and variables, and about different numeric data types. 

Problems

1

//First day
//Distance formula program
//This program calculates distance between two points

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

int main(void){
//Declared variables
double x1=2, y1=4, x2=2, y2=4, side1, side2, distance;
//Compute side length
side1=x2-x1;
side2=y2-y1;
//Compute distance between points
distance=sqrt(side1*side1 + side2*side2);
//Print distance between points
printf("The distance between the two points is %5.2f \n",      distance);
return 0;
}





Homework


One meter is equivalent to 0.00062137 miles, and therefore to convert from meters to miles, I simply multiply by this constant. 


I looked up the formula for converting degrees Celsius to  degrees Rankine, and inputted this formula in. This formula would take the inputted value of degrees Celsius and convert it to Rankine when the program is run.


 The area of an ellipse with semi-major axes of length a and b is pi*a*b. I used this formula to calculate my result.

The area of a sector of a circle with an angle d degrees between its radii is pi*r^2 multiplied by d/360, since it is a fraction of a circle, and that fraction can be found by dividing the degrees between the radii by the total number of degrees in a circle. 


Comments

Popular posts from this blog

Day 25: Python, Graphing, 3D Visualization and Inertial Measurement

Python Arduino Code int trigPin=13; //Sensor Trig pin connected to Arduino pin 13 int echoPin=11; //Sensor Echo pin connected to Arduino pin 11 float pingTime; //time for ping to travel from sensor to target and return float targetDistance; //Distance to Target in inches float speedOfSound=776.5; //Speed of sound in miles per hour when temp is 77 degrees. void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(trigPin, LOW); //Set trigger pin low delayMicroseconds(2000); //Let signal settle digitalWrite(trigPin, HIGH); //Set trigPin high delayMicroseconds(15); //Delay in high state digitalWrite(trigPin, LOW); //ping has now been sent delayMicroseconds(10); //Delay in low state pingTime = pulseIn(echoPin, HIGH); //pingTime is presented in microceconds pingTime=pingTime/1000000; //convert pin...

Day 19: Project 2

Our project was a test stand for rocket motors Using an LCD screen, we could choose a display mode, and it would display the selected value. Unfortunately, we were unable to calibrate the pressure sensor, so all we ended up with was a load cell. We used the HX711 library for this. The LCD screen displayed the maximum force experienced during the test Code for MotorSensors.h #ifndef _MOTORSENSORS_ #define _MOTORSENSORS_ #include <LiquidCrystal.h> //Include Liquid Crystal Library #include <HX711.h> //Include HX711 Load Cell library #include "HX711.h" //Include Load Cell header file #include <math.h> //Include math library #define calibration_factor -8815 //set calibration factor #define DAT 3 //define DAT pin #define CLK 2 //define CLK pin #define pressurePin A1 #define tempPin A2 HX711 scale(DAT,CLK);  LiquidCrystal lcd(8,9,4,5,6,7); //Define LCD pins //Initialize variables float maxkg=0;  float currentval=0; float maxforce=0; char mo...