Posts

Showing posts from June, 2017

Day4

Image
the above is the code for the rgb code  this is how i implemented the teal orange and white color modes. the colors changes after pressing a button. The orange and Teal color blinks automatically though.

Day17

Image
const int LEDPIN = 13; int LEDSTATE = LOW; unsigned long previousMillis = 0; const long interval = 800; void setup() {   pinMode(LEDPIN, OUTPUT); } void loop() {   unsigned long currentMillis = millis();   if(currentMillis - previousMillis >= interval)   {     previousMillis = currentMillis;     if (LEDSTATE == LOW)     {      LEDSTATE = HIGH;      } else         {           LEDSTATE = LOW;           };      digitalWrite(LEDPIN, LEDSTATE);      } } the code didn't work as it didn't compile. const int Button_int =0; co...

Day11

Image
the serial print displayed values that looks nice so i belive thew lab code is working.

Day21

Image
the output on the serial port says ther's nothing to be found so i believe it i htink its the wiring, or a stupid mistake in the code

Day15

//Simple Motor Speed Control Program const int MOTOR=9; //Motor on Digital Pin 9 void setup() { pinMode (MOTOR, OUTPUT); } void loop() { for (int i=0; i<256; i++) { analogWrite(MOTOR, i); delay(10); } delay(2000); for (int i=255; i>=0; i--) { analogWrite(MOTOR, i); delay(10); } delay(2000); } i got the code to make the motor run , but the potentiometer didn't change the speed of the motor, but as a on and off switch. i strongly think its because i didn't wire it correctly.

Day16

Image
/*  This program reads the information for a hurricane        */ /*  from a data file and then prints it.                      */ #include <stdio.h> #define FILENAME "storms.txt" /*  Define structure to represent a hurricane.  */ struct hurricane { char name[10]; int year, category; }; int main(void) { /*  Declare variables.  */ struct hurricane h1; FILE *storms; /*  Read and print information from the file.  */ storms = fopen(FILENAME,"r"); if (storms == NULL) printf("Error opening data file. \n"); else { while (fscanf(storms,"%s %d %d",h1.name,&h1.year, &h1.category) == 3) { printf("Hurricane: %s \n",h1.name); printf("Year: %d, Category: %d \n",h1.year, h1.category); } fclose(storms); } this si th ecode for the hurricane program with the storms .txt the storms .txt the program was not working so there is no output....

Day18

Image
#include <TimerOne.h> const int BUTTON_INT = 0; const int SPEAKER = 12; #define NOTE_C 65 #define NOTE_D 73 #define NOTE_E 82 #define NOTE_F 87 #define NOTE_G 98 #define NOTE_A 110 #define NOTE_B 123 volatile int key = NOTE_C; volatile int octave_multiplier = 1; void setup() { Serial.begin(9600); pinMode(SPEAKER,OUTPUT); attachInterrupt(BUTTON_INT, changeKey, RISING); Timer1.initialize(500000); Timer1.attachInterrupt(changePitch); } void changeKey() { octave_multiplier = 1; if (key == NOTE_C) key = NOTE_D; else if (key == NOTE_D) key = NOTE_E; else if (key == NOTE_E) key = NOTE_F; else if (key == NOTE_F) key = NOTE_G; else if (key == NOTE_G) key = NOTE_A; else if (key == NOTE_A) key = NOTE_B; else if (key == NOTE_B) key = NOTE_C; } void changePitch() { octave_multiplier = octave_multiplier * 2; if (octave_multiplier > 16 ) octave_multiplier = 1; tone (SPEAKER, key*octave_multiplier); } void loop () { Serial.print("...

Day20

Image
//SD read and write #include <SD.h> #include <Wire.h> #include <RTClib.h> const int CS_PIN =10; const int POW_PIN =8; //Default rate of 5 seconds int refresh_rate = 5000; //defining an abject RTC_DS1307 RTC; String year, month, day, hour , minute , second, time , date; void setup() { Serial.begin(9600); Serial.println("Initializing Card"); //CS pin is an output pinMode(CS_PIN, OUTPUT); Wire.begin(); RTC.begin(); if (!RTC.isrunning()) { Serial.println(F("RTC is not runnng")); RTC.adjust(DateTime(__DATE__,__TIME__)); } //Card will draw power from pin 8, so set it high pinMode(POW_PIN, OUTPUT); digitalWrite(POW_PIN, HIGH); if (!SD.begin(CS_PIN)) { Serial.println("Card Failure"); return; } Serial.println("Card Ready"); //Read the configuration information (speed.txt) File commandFile = SD.open("speed.txt"); if (commandFile) { Serial.println("Reading Command File"); whi...

Day14

Image
the el nino original code, i i've done the homework but unfortunately i can't find the code with the homework questions either. the enso.txt numbers the output of the code

Day6

Image
the photo-resistor  lab and nightlight homework setup.  The lab button with the led to turn on and off setup. the code is from the lab pdf.  One of them didn't work, dont' remember.

Day5

Image
the setup for the pot checking the serial port for the values to change. the code and the output on the right. the values seems to change as i change the potentiometer.

Day19

Image
the SD logging code modified to get temperature and read the data. The output was working in class , but the arduino doesn't want to run for some reason now. the code does work  if there is the speed.txt . the setup of the sd card reader and the i2c . wiring for general is sometimes confusing for me so this part took time from the wring.

Day8

Image
this code is the rand code and i think it should of been on day 7 but i'm putting it here as day 8 because i put the recursion in day 7.  the program took 3 values from the user and prints out how ever many random values the user wanted and the range of the random numbers.

Day12

Image
the code using the I2C  temperature sensor and using the RGB LED to display the temperature. the code was easy , but the wiring was confusing. Trying to wire it correctly part of the problem to get it to work. this is before the lights were connected, and i was used on the lab. The pin that wasn't used threw me off on the wiring. The elevation code, but modified for the homework. This HW was fairly easy because it was just mainly creating loops and counters or copying and modifying the already existing loop. This code is actually from the final as i can't find the original code. the output of the elevation code. 

Day10

Image
the program to find the mean,  median, variance, and std dev, in array[a], array[b]. the output seems to be correct. i didn't forgot how to set the precision of the decimal values so there were a lot of 0's after the number which weren't necessary. maybe should of parsed them into int , but the output seems readable. Finding the right %_  or the type of value took some time for me as i wan't sure how to print in C as cout is much easier .

Day9

Image
the the servo motor with the distance sensor sweeping  and stay where the closest point was. my attempt at doing the occupied or empty homework with the servos. Arduino didn't want to cooperate so i just wrote it in a text file. I think i got the logic right .

Day7

Image
the code for the sound lab using the cheap speaker. as with all the labs and project using the speaker, trying to get the thin wires to get into the breadboard and having it stay there took the longest. the lecture code for the recursive and non-recursive code for factorials the output for the factorials. they both seem alright and bad. JDoodle did have a small cap so i think higher numbers just gets capped.

Day13

Image
the temperature homework with the I2C  the output of the code homework. when the button is pressed it changes from C to F and vica versa. i didn't know how to fix the 2 symbols that comes after the output. it has something wiht how the LCD screen output works that i havn't figured out.

Day3

Image
the above 2 are the math code that outputs the log base 2 of a number that is taken from input. the blink code the led blinks the way it should

Day22

Image
this is a part of the hand distance code, not too difficult other than the last problem. don't think i's working. the input and output of the hands code. it seems like it's working well except problem 5. the problem with the MPU lab was creating separate files. although it wasn't hard it just wasn't clear that i had to include 2 files.