Posts

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("...