Posts

Showing posts from December, 2017

Project_3

Image
Comment: This project was definitely the hardest thing I did in ENGR6. I did learn a lot about using libraries in arduino, which are basically header file in C/C++. It was nice that Mason provided everyone with the libraries, and code to run all the  modules. Our group replaced two of the nano, since they were buggy and had difficulty uploading code to the arduino. Compiling everything wasn't too bad, it was more the dynamic memory allocation that we were worried about. Fortunately, David told us that we could delete a part of code for the MPU module that saved us a lot of memory.We did get everything to work, except the python is buggy. We also, had trouble on the launch day, with the battery dying, and my group not having a hole for the switch to turn on the arduino. Fortunately,we finished in just the nick of time, and got back good data.  //Reading Acceleration, Gyro, and Pressure Data ---> writing to SD card //#include <TimerOne.h> //#include <SD.h> #in...

day 21 Hw

#include <iostream> #include <cmath> #include<fstream> #include<string> using namespace std; int main(void) { // fstream unknownf; // unknownf.open("unknownf.txt",ios::in | ios::out); // // if (!unknownf.is_open()) // { // cout << " File didn't open"; // } //else //{ // char word[50]; // unknownf << word; // while(unknownf.good()) // { // // } // // //unknownf.close(); //} //Declare and initialize variables.  int n; double unknown[5], known[5]={6.2,7.0,8.0,7.4,5.8}; double distance(double hand_1[5],double hand_2[5]); // Compute and print distance. for(n=0;n<5;n++) { cout << "Enter elements:" << endl; cin >> unknown[n]; } fstream unknownf; unknownf.open("unknownf.txt",ios::in | ios::out); if (!unknownf.is_open()) { cout << " File didn't open"; } else {  char word[50];  unknownf << word;  int i=...

Day_23

Image
Comment: With this homework I had a lot of trouble understanding classes. I watched a lot of you tube videos on how classes work, but I feel like everyone had a different way of writing classes. I got David to help me finish the code. He emphasize how important  structures are so I better understand them before the final. //ClassDate.cpp #include <iostream> using namespace std; using std::cout; using std::cin; using std::endl; //class definition class Date{ private:                               // User manipuation. int month; int day; int year; public:                             // Only the program can change this. Date(); Date(int month,int day,int year); void print_f1();                    //format 1. 01/01/2014 void print_f2();...

Day 20 HW

Image
Comment: Got the code to work, didn't take too long to figure out how to finish the two problems. #include <stdio.h> int a[]={1,9,3,4,7,19,35,15,20},p=0,r=9; int partition(int a[], int p, int r); void quicksort(int a[], int p, int r) { if(p < r) { int q; q = partition(a, p, r); quicksort(a, p, q); quicksort(a, q+1, r); } } int partition(int a[], int p, int r) { int i, j, pivot, temp; pivot = a[p]; i = p; j = r; while(1) { while(a[i] < pivot && a[i] != pivot) i++; while(a[j] > pivot && a[j] != pivot) j--; if(i < j) { temp = a[i]; a[i] = a[j]; a[j] = temp; } else { return j; } } } int main(void){ quicksort(a,p,r-1); printf("numbers:"); for(int k=0;k<=8;k++) { printf("\n %i",a[k]); } return 0; }

Project_2

Image
Comment: I thought that this project would be easier then the first project, since we had our lcd, modules, and the majority of the code figured out. I was very wrong, compiling and getting all the modules integrated into the arduino was a night mare.  Calibrating the heartbeat sensor and alcohol sensor was the biggest problem that we faced on the project. A nice thing for the project is that we used functions, which we didn't used with the first project. After pulling an all nighter, Mathew and i finished the project, the only thing we couldn't get to work was the Bluetooth module. No matter how hard we tried we couldn't get the arduino to transmit data.   #include <LiquidCrystal.h> LiquidCrystal lcd(8,9,4,5,6,7); /*---Create the square for the bar-----*/ byte p100[8] = {  B11111,  B11111,  B11111,  B11111,  B11111,  B11111,  B11111,  B11111, }; /*-----Alcohol Sensor Constants------*/ const int alc...