diff --git a/.DS_Store b/.DS_Store index d708e00..05159ae 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/JPNS 101/Assignments/ホールドラップ-101-1-134ページ.pdf b/JPNS 101/Assignments/ホールドラップ-101-1-134ページ.pdf new file mode 100644 index 0000000..c5fec7f Binary files /dev/null and b/JPNS 101/Assignments/ホールドラップ-101-1-134ページ.pdf differ diff --git a/JPNS 101/Assignments/ホールドラップ-101-1-32ページ.pdf b/JPNS 101/Assignments/ホールドラップ-101-1-32ページ.pdf new file mode 100644 index 0000000..829d50f Binary files /dev/null and b/JPNS 101/Assignments/ホールドラップ-101-1-32ページ.pdf differ diff --git a/JPNS 101/Assignments/ホールドラップ-101-1-33ぺージ.pdf b/JPNS 101/Assignments/ホールドラップ-101-1-33ぺージ.pdf new file mode 100644 index 0000000..204393f Binary files /dev/null and b/JPNS 101/Assignments/ホールドラップ-101-1-33ぺージ.pdf differ diff --git a/JPNS 101/Assignments/ホールドラップ-101-1-34ページ.pdf b/JPNS 101/Assignments/ホールドラップ-101-1-34ページ.pdf new file mode 100644 index 0000000..584a03d Binary files /dev/null and b/JPNS 101/Assignments/ホールドラップ-101-1-34ページ.pdf differ diff --git a/JPNS 101/Assignments/ホールドラップ-101-1-35ページ.pdf b/JPNS 101/Assignments/ホールドラップ-101-1-35ページ.pdf new file mode 100644 index 0000000..9f60f06 Binary files /dev/null and b/JPNS 101/Assignments/ホールドラップ-101-1-35ページ.pdf differ diff --git a/JPNS 101/Assignments/ホールドラップ-101-1-36-ページ.pdf b/JPNS 101/Assignments/ホールドラップ-101-1-36-ページ.pdf new file mode 100644 index 0000000..52789d9 Binary files /dev/null and b/JPNS 101/Assignments/ホールドラップ-101-1-36-ページ.pdf differ diff --git a/JPNS 101/Assignments/ホールドラップ-101-1-37ページ.pdf b/JPNS 101/Assignments/ホールドラップ-101-1-37ページ.pdf new file mode 100644 index 0000000..cfe781a Binary files /dev/null and b/JPNS 101/Assignments/ホールドラップ-101-1-37ページ.pdf differ diff --git a/JPNS 101/Assignments/ホールドラップ-101-1-41ページ.pdf b/JPNS 101/Assignments/ホールドラップ-101-1-41ページ.pdf new file mode 100644 index 0000000..c1da7bd Binary files /dev/null and b/JPNS 101/Assignments/ホールドラップ-101-1-41ページ.pdf differ diff --git a/JPNS 101/Assignments/ホールドラップ-101-1-42ページ.pdf b/JPNS 101/Assignments/ホールドラップ-101-1-42ページ.pdf new file mode 100644 index 0000000..b82cca9 Binary files /dev/null and b/JPNS 101/Assignments/ホールドラップ-101-1-42ページ.pdf differ diff --git a/PHYS112/GH_CH_KM_Demo-Based Quiz on Mirrors and Lenses.docx b/PHYS112/GH_CH_KM_Demo-Based Quiz on Mirrors and Lenses.docx new file mode 100644 index 0000000..759ae31 Binary files /dev/null and b/PHYS112/GH_CH_KM_Demo-Based Quiz on Mirrors and Lenses.docx differ diff --git a/PHYS112/Garrett Haldrup.docx b/PHYS112/Garrett Haldrup.docx new file mode 100644 index 0000000..df5b38a Binary files /dev/null and b/PHYS112/Garrett Haldrup.docx differ diff --git a/PHYS112/Haldrup Formal Report 1.docx b/PHYS112/Haldrup Formal Report 1.docx new file mode 100644 index 0000000..fd47c66 Binary files /dev/null and b/PHYS112/Haldrup Formal Report 1.docx differ diff --git a/PHYS112/HaldrupHW4.pdf b/PHYS112/HaldrupHW4.pdf new file mode 100644 index 0000000..f2ffae2 Binary files /dev/null and b/PHYS112/HaldrupHW4.pdf differ diff --git a/PHYS112/HaldrupHW6.pdf b/PHYS112/HaldrupHW6.pdf new file mode 100644 index 0000000..69a9e19 Binary files /dev/null and b/PHYS112/HaldrupHW6.pdf differ diff --git a/PHYS112/HaldrupRQ2.pdf b/PHYS112/HaldrupRQ2.pdf new file mode 100644 index 0000000..905d7c5 Binary files /dev/null and b/PHYS112/HaldrupRQ2.pdf differ diff --git a/PHYS112/Hw7Haldrup.pdf b/PHYS112/Hw7Haldrup.pdf new file mode 100644 index 0000000..393f39b Binary files /dev/null and b/PHYS112/Hw7Haldrup.pdf differ diff --git a/PHYS112/Lab 10.pdf b/PHYS112/Lab 10.pdf new file mode 100644 index 0000000..a0e116a Binary files /dev/null and b/PHYS112/Lab 10.pdf differ diff --git a/PHYS112/Lab 10kaitgarrettchristopher.pdf b/PHYS112/Lab 10kaitgarrettchristopher.pdf new file mode 100644 index 0000000..05d03f6 Binary files /dev/null and b/PHYS112/Lab 10kaitgarrettchristopher.pdf differ diff --git a/PHYS112/Reflection and Refraction Lab Report Outline.pdf b/PHYS112/Reflection and Refraction Lab Report Outline.pdf new file mode 100644 index 0000000..7f90f07 Binary files /dev/null and b/PHYS112/Reflection and Refraction Lab Report Outline.pdf differ diff --git a/PHYS112/SenatorLetterGarrett.docx b/PHYS112/SenatorLetterGarrett.docx new file mode 100644 index 0000000..8b36dce Binary files /dev/null and b/PHYS112/SenatorLetterGarrett.docx differ diff --git a/Research/pygameSim/CytoSim b/Research/pygameSim/CytoSim index 41c2aec..a63285a 160000 --- a/Research/pygameSim/CytoSim +++ b/Research/pygameSim/CytoSim @@ -1 +1 @@ -Subproject commit 41c2aecf88dee9efe9896171d4d70dc89f0c4d75 +Subproject commit a63285a8b51d61877433cc18100fbd584eb91bee diff --git a/csci218/Assignments/output/pi.out b/csci218/Assignments/output/pi.out index bec3702..eba4c17 100755 Binary files a/csci218/Assignments/output/pi.out and b/csci218/Assignments/output/pi.out differ diff --git a/csci218/Assignments/pi.c b/csci218/Assignments/pi.c index 1b21bf8..95be568 100644 --- a/csci218/Assignments/pi.c +++ b/csci218/Assignments/pi.c @@ -1,3 +1,10 @@ +/* Name: Garrett Haldrup +pi.c +Problem: Experiments with different methods of calculating pi, and sees how close they get to the real thing +Certification of Authenticity: +I certify that this assignment is entirely my own work. +*/ + #include #include @@ -10,9 +17,12 @@ void piCompare(double pi); int main() { - int n = 10000; + int n; double pi; + printf("Enter the number of n iterations to do\nfor each method of calculating pi: "); + scanf("%d", &n); + pi = piWallis(n); piCompare(pi); pi = piGregory(n); @@ -27,6 +37,9 @@ double piWallis(int n) { int top = 0; int bottom = 1; double pi = 1; + + printf("\nThis will calculate pi using the Wallis Method.\n"); + for (int i = 0; i < n; i++) { top += ((i + 1) % 2) * 2; bottom += (i % 2) * 2; @@ -42,6 +55,8 @@ double piGregory(int n) { int bottom = 1; double pi = 0; + printf("\nThis will calculate pi using the Gregory Method.\n"); + for (int i = 0; i < n; i++) { bottom = (1 + (2 * i)) * pow(-1, i); pi += (float)top / (float)bottom; @@ -55,6 +70,8 @@ double piNilakantha(int n) { int bottom; double pi = 3; + printf("\nThis will calculate pi using the Nilakantha Method.\n"); + for (int i = 1; i < n; i++) { bottom = (2*i) * (2*i+1) * (2*i+2) * pow(-1, i - 1); pi += (float)top / (float) bottom; @@ -68,6 +85,8 @@ double piEuler(int n) { int bottom; double pi = 0; + printf("\nThis will calculate pi using the Euler Method.\n"); + for (int i = 0; i < n; i++) { bottom = pow(i+1,2); pi += 1.0 / bottom; @@ -81,5 +100,5 @@ void piCompare(double pi) { double diff; diff = M_PI - pi; - printf("%lf\n", diff); + printf("The difference from the actual value of pi is: %lf\n", diff); } diff --git a/csci218/Labs/.DS_Store b/csci218/Labs/.DS_Store index 161b98c..81388cf 100644 Binary files a/csci218/Labs/.DS_Store and b/csci218/Labs/.DS_Store differ diff --git a/csci218/Labs/Final Project/.DS_Store b/csci218/Labs/Final Project/.DS_Store new file mode 100644 index 0000000..d43c00a Binary files /dev/null and b/csci218/Labs/Final Project/.DS_Store differ diff --git a/csci218/Labs/Final Project/RotaryEncoder/RotaryEncoder.ino b/csci218/Labs/Final Project/RotaryEncoder/RotaryEncoder.ino new file mode 100644 index 0000000..2222f31 --- /dev/null +++ b/csci218/Labs/Final Project/RotaryEncoder/RotaryEncoder.ino @@ -0,0 +1,48 @@ +#define outputA 2 +#define outputB 3 +#define buttonPin 8 + +int counter = 0; +int aState; +int aLastState; +int buttonState; +int lastButtonState; + +void setup() { + // put your setup code here, to run once: + pinMode(outputA, INPUT); + pinMode(outputB, INPUT); + pinMode(buttonPin, INPUT_PULLUP); + + Serial.begin(9600); + aLastState = digitalRead(outputA); + +} + +void loop() { + // put your main code here, to run repeatedly: + + buttonState = digitalRead(buttonPin); + + aState = digitalRead(outputA); + + if (aState != aLastState) { + if(digitalRead(outputB) != aState) { + counter++; + } else { + counter--; + } + Serial.print("Position: "); + Serial.println(counter); + } + + if (!buttonState && buttonState != lastButtonState) { + counter /= 2; + Serial.print("Position: "); + Serial.println(counter); + } + + + lastButtonState = buttonState; + aLastState = aState; +} diff --git a/csci218/Labs/Lab10/Pull Down.heic b/csci218/Labs/Lab10/Pull Down.heic new file mode 100644 index 0000000..0f4463f Binary files /dev/null and b/csci218/Labs/Lab10/Pull Down.heic differ diff --git a/csci218/Labs/Lab10/Pull Down.png b/csci218/Labs/Lab10/Pull Down.png new file mode 100644 index 0000000..cb858af Binary files /dev/null and b/csci218/Labs/Lab10/Pull Down.png differ diff --git a/csci218/Labs/Lab10/RGB_LED/RGB_LED.ino b/csci218/Labs/Lab10/RGB_LED/RGB_LED.ino new file mode 100644 index 0000000..0ee681a --- /dev/null +++ b/csci218/Labs/Lab10/RGB_LED/RGB_LED.ino @@ -0,0 +1,60 @@ +// Define Pins & Delay +#define BLUE 4 +#define GREEN 5 +#define RED 6 +#define DELAY 10 + +// define global variables +int redValue; +int greenValue; +int blueValue; +int redDir = -1; +int greenDir = 1; +int blueDir = 0; + + +void setup() { + pinMode(RED, OUTPUT); + pinMode(GREEN, OUTPUT); + pinMode(BLUE, OUTPUT); + + redValue = 0; + greenValue = 0; + blueValue = 255; + + analogWrite(RED, redValue); + analogWrite(GREEN, greenValue); + analogWrite(BLUE, blueValue); + + Serial.begin(9600); + +} + + + +// main loop +void loop() { + if (redValue == 255) { + redDir = -1; + greenDir = 1; + blueDir = 0; + } else if (greenValue == 255) { + redDir = 0; + greenDir = -1; + blueDir = 1; + } else if (blueValue == 255) { + redDir = 1; + greenDir = 0; + blueDir = -1; + } + + redValue += redDir; + greenValue += greenDir; + blueValue += blueDir; + + analogWrite(RED, redValue); + analogWrite(GREEN, greenValue); + analogWrite(BLUE, blueValue); + + delay(DELAY); +} diff --git a/csci218/Labs/Lab10/a.out b/csci218/Labs/Lab10/a.out new file mode 100755 index 0000000..8d9ed93 Binary files /dev/null and b/csci218/Labs/Lab10/a.out differ diff --git a/csci218/Labs/Lab10/halfAdder/halfAdder.ino b/csci218/Labs/Lab10/halfAdder/halfAdder.ino new file mode 100644 index 0000000..9d31384 --- /dev/null +++ b/csci218/Labs/Lab10/halfAdder/halfAdder.ino @@ -0,0 +1,27 @@ +int buttonA = 2; +int buttonB = 3; + +void setup(){ + Serial.begin(9600); + pinMode(buttonA, INPUT_PULLUP); + pinMode(buttonB, INPUT_PULLUP); + pinMode(10, OUTPUT); //Sum, Red LED + pinMode(12, OUTPUT); //Carryout, Yellow LED +} + +void loop() { + int inputA = digitalRead(buttonA); // read voltage on pin + int inputB = digitalRead(buttonB); + + if(inputA && inputB) { + digitalWrite(10, LOW); + digitalWrite(12, HIGH); + } else if (inputA || inputB) { + digitalWrite(10, HIGH); + digitalWrite(12, LOW); + + } else { + digitalWrite(10, LOW); + digitalWrite(12, LOW); + } +} diff --git a/csci218/Labs/Lab10/lab10.c b/csci218/Labs/Lab10/lab10.c new file mode 100644 index 0000000..8805149 --- /dev/null +++ b/csci218/Labs/Lab10/lab10.c @@ -0,0 +1,95 @@ + +/* Name: Garrett Haldrup +# lab10.c +# Purpose: Solves problems assigned in Lab 10 + +*/ + +#include +#include +#include + + +float distance(float x1, float y1, float x2, float y2); +float perimeterOfTriangle(float x1, float y1, float x2, float y2, float x3, float y3); +float circleArea(float radius); +char scoreToLetter(int score); + +int main(){ + + float x1, y1, x2, y2, x3, y3; + x1 = 1, y1 = 2, x2 = 4, y2 = 6, x3 = 5, y3 = 3; + char list[] = {'F', 'D', 'E', 'C', 'B', 'A', 'N'}; + int count = 0; + + printf("\nTest cases for score to letter\n"); + for (int i = 51; i <= 101; i += 10) { + char grade = scoreToLetter(i); + assert(grade = list[count]); + printf("The score of %d is letter grade: %c\n", i, scoreToLetter(i)); + printf("Pass!---------------------------------------------------\n"); + count++; + } + + //test example + printf("\n\ntest distance(): \n"); + float radius = distance(x1, y1, x2, y2); + assert(radius == 5.00); + printf("Pass!---------------------------------------------------\n"); + + printf("\n\ntest circleArea(): \n"); + float area = circleArea(radius); + assert((int)area == 78); + printf("Pass!---------------------------------------------------\n"); + + printf("\n\ntest perimeterOfTriangle(): \n"); + float perimeter = perimeterOfTriangle(x1, y1, x2, y2, x3, y3); + assert((int)perimeter == 12); + printf("Pass!---------------------------------------------------\n"); + + + return 0; +} + +char scoreToLetter(int score) { + switch (score) { + case 60 ... 69: + return 'D'; + break; + case 70 ... 79: + return 'C'; + break; + case 80 ... 89: + return 'B'; + break; + case 90 ... 100: + return 'A'; + break; + default: + if (score < 0 || score > 100) { + return 'N'; + } else { + return 'F'; + } + break; + } +} + +float distance(float x1, float y1, float x2, float y2) { + float distance = sqrt(pow(x1 - x2, 2)+pow(y1 - y2, 2)); + return distance; +} + +float perimeterOfTriangle(float x1, float y1, float x2, float y2, float x3, float y3) { + + float perimeter = distance(x1, y1, x2, y2) + distance(x2, y2, x3, y3) + distance(x3, y3, x1, y1); + + return perimeter; +} + +float circleArea(float radius) { + + float area = M_PI * pow(radius, 2); + + return area; +} diff --git a/csci218/Labs/Lab10/pushButton/pushButton.ino b/csci218/Labs/Lab10/pushButton/pushButton.ino new file mode 100644 index 0000000..026da65 --- /dev/null +++ b/csci218/Labs/Lab10/pushButton/pushButton.ino @@ -0,0 +1,30 @@ +// constants won't change. They're used here to +// set pin numbers: +const int buttonPin = 2; // the number of the pushbutton pin +const int ledPin = 10; // the number of the LED pin +// variables will change: +int buttonState = 0; // variable for reading the pushbutton status +void setup() { + Serial.begin(9600); + // initialize the LED pin as an output: + pinMode(ledPin, OUTPUT); + // initialize the pushbutton pin as an input: + pinMode(buttonPin, INPUT); +} +void loop() { + // read the state of the pushbutton value: + buttonState = digitalRead(buttonPin); + // Show the state of pushbutton on serial monitor + Serial.println(buttonState); + // check if the pushbutton is pressed. + // + if (buttonState == 1) { + // turn LED on: + digitalWrite(ledPin, HIGH); + } else { + // turn LED off: + digitalWrite(ledPin, LOW); + } + // Added the delay so that we can see the output of button + delay(50); +} diff --git a/csci218/Labs/Lab11/RGB_LED2/RGB_LED2.ino b/csci218/Labs/Lab11/RGB_LED2/RGB_LED2.ino new file mode 100644 index 0000000..c2c95c8 --- /dev/null +++ b/csci218/Labs/Lab11/RGB_LED2/RGB_LED2.ino @@ -0,0 +1,69 @@ +// Define Pins & Delay +#define BLUE 4 +#define GREEN 5 +#define RED 6 + +// define global variables +int redValue; +int greenValue; +int blueValue; +int redDir = -1; +int greenDir = 1; +int blueDir = 0; +int de = 10; +int potPin = A0; +int potValue; + + +void setup() { + pinMode(RED, OUTPUT); + pinMode(GREEN, OUTPUT); + pinMode(BLUE, OUTPUT); + + redValue = 0; + greenValue = 0; + blueValue = 255; + + analogWrite(RED, redValue); + analogWrite(GREEN, greenValue); + analogWrite(BLUE, blueValue); + + Serial.begin(9600); + +} + + + +// main loop +void loop() { + + potValue = analogRead(potPin); + + de = 1 + ((99.9 / 1023) * potValue); + Serial.println(de); + + + if (redValue == 255) { + redDir = -1; + greenDir = 1; + blueDir = 0; + } else if (greenValue == 255) { + redDir = 0; + greenDir = -1; + blueDir = 1; + } else if (blueValue == 255) { + redDir = 1; + greenDir = 0; + blueDir = -1; + } + + redValue += redDir; + greenValue += greenDir; + blueValue += blueDir; + + analogWrite(RED, redValue); + analogWrite(GREEN, greenValue); + analogWrite(BLUE, blueValue); + + delay(de); +} diff --git a/csci218/Labs/Lab11/a.out b/csci218/Labs/Lab11/a.out new file mode 100755 index 0000000..0f03159 Binary files /dev/null and b/csci218/Labs/Lab11/a.out differ diff --git a/csci218/Labs/Lab11/lab11.c b/csci218/Labs/Lab11/lab11.c new file mode 100644 index 0000000..68a47e3 --- /dev/null +++ b/csci218/Labs/Lab11/lab11.c @@ -0,0 +1,137 @@ +/* Name: Garrett Haldrup +# lab11.c +# Purpose: Solves problems assigned in Lab 11 + +*/ + +#include +#include +#include + +float findMax(float array[], int n); +float findMin(float array[], int n); +float getMean(float array[], int n); +float getStd(float array[], int n); +void raiseWages(float wages[], float raises[], int n); +void printArray(float array[], int n); + +int main() { + + printf("This program will calculate the max, min, mean, and std of a number set\n"); + printf("It will also update a wages array through a function call\n\n"); + + float result; + + float testFloats[] = {85, 93.3, 90.5}; + + float wages[] = {15.00, 14.75, 15.00, 19.50, 13.00}; + float raises[] = { 1.00, 2.00, 1.50, 0.00, 1.50}; + + float newWages[] = {16, 16.75, 16.5, 19.5, 14.5}; + + + int testFloatSize = sizeof(testFloats)/sizeof(testFloats[0]); + + int wageSize = sizeof(wages)/sizeof(wages[0]); + + + + result = findMax(testFloats, testFloatSize); + assert(result - 93.3 <= 0.001); + printf("Max of set is: %.1f\n", result); + printf("Pass!---------------------------------------------------\n"); + + result = findMin(testFloats, testFloatSize); + assert(result - 85.0 <= 0.001); + printf("Min of set is: %.1f\n", result); + printf("Pass!---------------------------------------------------\n"); + + result = getMean(testFloats, testFloatSize); + assert(result - 89.6 <= 0.001); + printf("Mean of set is: %.1f\n", result); + printf("Pass!---------------------------------------------------\n"); + + result = getStd(testFloats, testFloatSize); + assert(result - 3.4477 <= 0.001); + printf("Std of set is: %.1f\n", result); + printf("Pass!---------------------------------------------------\n"); + + printf("\n"); + + raiseWages(wages, raises, wageSize); + + for (int i = 0; i < wageSize; i++) { + printf("wages[%d] = %.2f = %.2f\n", i, wages[i], newWages[i]); + assert(wages[i] - newWages[i] <= 0.000001); + printf("Pass!---------------------------------------------------\n"); + } + + printArray(wages, wageSize); + + + + + + + return 0; +} + +float findMax(float array[], int n) { + float max = array[0]; + + for (int i = 1; i < n; i++) { + if (array[i] > max) { + max = array[i]; + } + } + + return max; +} + +float findMin(float array[], int n) { + float min = array[0]; + + for (int i = 1; i < n; i++) { + if (array[i] < min) { + min = array[i]; + } + } + + return min; +} + +float getMean(float array[], int n) { + float sum = 0; + + for (int i = 0; i < n; i++) { + sum += array[i]; + } + + return sum / n; +} + +float getStd(float array[], int n) { + float sum = 0; + float mean = getMean(array, n); + + for (int i = 0; i < n; i++) { + sum += pow(array[i] - mean, 2); + } + + return sqrt(sum / n); +} + +void raiseWages(float wages[], float raises[], int n) { + + for (int i = 0; i < n; i++) { + wages[i] += raises[i]; + } +} + +void printArray(float array[], int n) { + printf("{%.2f", array[0]); + for (int i = 1; i < n; i++) { + printf(", %.2f", array[i]); + } + printf("}\n"); +} diff --git a/csci218/Labs/Lab9/lab9.c b/csci218/Labs/Lab9/lab9.c index 5110111..f74d69d 100644 --- a/csci218/Labs/Lab9/lab9.c +++ b/csci218/Labs/Lab9/lab9.c @@ -30,7 +30,6 @@ int main() { void triangle() { int n = 10; char symbol = '*'; - int count = 1; printf("\nThis program will show a trangle with width of n = 10 and symbol '*'.\n"); @@ -43,7 +42,6 @@ void triangle() { } } printf("\n"); - count++; } } @@ -55,9 +53,9 @@ void multiplicationTable() { printf("Enter n for a n x n multiplcaiton table: "); scanf("%d", &n); - for (int i = 0; i < n; i++) { - for (int j = 0; j < n; j++) { - printf("%d\t", (i + 1) * (j + 1)); + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + printf("%d\t", i * j); } printf("\n"); } @@ -141,9 +139,9 @@ void triangleN(int n) { void multiplicationTableN(int n) { printf("\nThis program will make a %d x %d multiplication table.\n", n, n); - for (int i = 0; i < n; i++) { - for (int j = 0; j < n; j++) { - printf("%d\t", (i + 1) * (j + 1)); + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + printf("%d\t", i * j); } printf("\n"); } diff --git a/csci218/Labs/Lab9/lab9.out b/csci218/Labs/Lab9/lab9.out index c2a4852..f1c18cc 100755 Binary files a/csci218/Labs/Lab9/lab9.out and b/csci218/Labs/Lab9/lab9.out differ