Difference between revisions of "270j Final Project"

From CSclasswiki
Jump to: navigation, search
(Part 3)
(Part 3)
Line 67: Line 67:
  
 
==Part 3==
 
==Part 3==
Connect the fan blade and its motor to my Arduino. To verify that it works correctly, implement a push button. By default (when the program was initiated), the fan blade is not operating. It will only start to operate after the button is pressed. It will stop operating if the button is pressed again.
+
Connect the fan blade and its motor to my Arduino. To verify that it works correctly, a push button is implemented. By default (when the program was initiated), the fan blade is not operating. It will only start to operate after the button is pressed. It will stop operating if the button is pressed again.
  
 
==Part 4==
 
==Part 4==

Revision as of 16:51, 6 May 2020

Project Proposal

This is an Arduino-Only project.

Goal

The goal of this project is to implement a safety fan blade whose rotational speed is dependent on the distance between an ultrasonic sensor and an object in front of it. The distance is read from the ultrasonic sensor. The smaller the distance, the slower the fan will operate; and when the distance is smaller than 5cm, the fan will stop operating.

External References

Part 1

Connect a 64-LED matrix display to my Arduino and program it to display my name "NOX".

Schematic

Wiring of a 8x8 LED matrix to Arduino Mega2650

Source Code

The following program displays the letters 'N', 'O', 'X' one at a time repeatedly.

/*  
 *  led64
 *  Nox Yu 
 *  part 1 of the final project for csc270
 *  this program makes the 8x8 LED matrix displays N, O, X, one at a time repeatedly
 */
#include <LedControl.h>

int DIN = 12;
int CS = 11;
int CLK = 10;
byte n[8] = {0xE3, 0xF3, 0xFB, 0xDD, 0xDD, 0xCF, 0xCF, 0xC7};
byte o[8] = {0x3C, 0x7E, 0xE7, 0xC3, 0xC3, 0xE7, 0x7E, 0x3C};
byte x[8] = {0x81, 0xC3, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0xC3};
LedControl lc = LedControl(DIN, CLK, CS, 0);

// display each row on the matrix according to the bytes array input
void printByte(byte bytes[]){
  int i=0;
  for (i=0; i<8; i++ ){
    lc.setRow(0, i, bytes[i]); 
  }
}

void setup() {
  // put your setup code here, to run once:
  lc.shutdown(0, false); // shutdown the power saving mode
  lc.setIntensity(0, 15); // set brightness to max
  lc.clearDisplay(0);
}

void loop() {
  // put your main code here, to run repeatedly:
  printByte(n);
  delay(1000);
  printByte(o);
  delay(1000);
  printByte(x);
  delay(1000); 
}

Part 2

Connect an ultrasonic sensor to my Arduino. To verify that it works correctly, the 4-digit-7-segment display will show the distance between the sensor and an object in front of it in cm.

Part 3

Connect the fan blade and its motor to my Arduino. To verify that it works correctly, a push button is implemented. By default (when the program was initiated), the fan blade is not operating. It will only start to operate after the button is pressed. It will stop operating if the button is pressed again.

Part 4

The fan blade's rotational speed should be proportional to the temperature read from the temperature sensor. It should have four levels:

  • below 15 degrees Celsius: fan does not rotate
  • between 15 and 25 Celsius: fan operates at 1/3 of its maximum rotational speed
  • between 25 and 30 Celsius: fan operates at 2/3 of its maximum rotational speed
  • above 30 Celsius: fan operates at its maximum rotational speed