231a-ak project

From CSclasswiki
Jump to: navigation, search

Main | Lab | Project | Demos | Resources

Lei Lei Project

Project goal for CSC 231 Assembly language is to play with Arduino chip and program it and make it talk to other devices or software. My Project is building a Hard Drive Clock. Details can be found in the links below.

Preparing Hardware

1. Take apart the hard drive. Remove the seek hand and data input wires. Leave only the platters. Remove the bottom platter to leave space for sensor and LEDs.
2. Cut a slot on the upper platter.
below

3. Test the beam sensor on the breadboard first, making sure the wiring doesn't allow too high voltages for the sensor.
below

below

4. Solder the parts, and glue the parts onto the base of the hard drive. keep the main circuit on the mother board and Arduino.
below

below

below

5. Screw the the cut platter back.
below

Test the Hardware with Arduino

Using the sketch blow. Whenever sensor detects the slot on the platter, it sends a value that's larger than 10 to input analog pin, now set all LEDs to HIGH.

int intPin = 2;
int ledPin4 = 4;
int ledPin5 = 5;
int ledPin6 = 6;
int val;

void setup()                    // run once, when the sketch starts
{
  beginSerial(9600);
  pinMode(intPin, INPUT);
  pinMode(ledPin4, OUTPUT);      // sets the digital pin2 as output
  pinMode(ledPin5, OUTPUT);      // sets the digital pin3 as output
  pinMode(ledPin6, OUTPUT);      // sets the digital pin4 as output
}

void loop()                     // run over and over again
{
  val = digitalRead(intPin);
  if (val == HIGH ) {
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, HIGH);
    digitalWrite(ledPin6, HIGH);
    delay(100);
  }
  if (val == LOW) {
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
    digitalWrite(ledPin6, LOW);
    delay(100);
  }
}