Lab 03 - distractions and more

The week's labs dealt with analog inputs and analog outputs concerning small speakers and servo motors. I did the labs, and I photos to prove it. But I think I am going to focus this week's post on my physical computing distraction this week.

First here are some photo's, because I did the labs, I promise.

digi-out

BUT. Once I finished the lab I decided I wasn't quite done with physical computing for the day. After rummaging through the junk shelf, I found an old hard drive.

I wish I documented my taking it apart, as it was quite a production. But my assumption was that I would find a ton of cool motors and fans. Luckily I did.

digi-out digi-out

I decided too see if I could get the gear on the motor to follow my finger based on a photocell. A photocell isn't quite the right sensor for this job. Because it only will indiciate how much light is in its range, it is difficult to determine where an obstruction might have moved. My solution was to have the Arduino search for the light obstruction ( my finger ) and stop when it finds it. Video and code below:

int aPin = A0;
int dpin1 = 3;
int dpin2 = 4;
bool hit = false;
bool left = false;
int count = 0;

void setup() {
  pinMode(dpin1,OUTPUT);
  pinMode(dpin2,OUTPUT);  
  Serial.begin(9600);
}
int search(){
  left = !left;
  if (left){
     digitalWrite(dpin1, LOW);
     digitalWrite(dpin2, HIGH);
    
  }else{
     digitalWrite(dpin1, HIGH);
     digitalWrite(dpin2, LOW);
    
  } 
  delay(200); 
}
    
void loop() {
  if (analogRead(aPin) > 600 ){
    search();
  }
  
Serial.println(analogRead(aPin));
}
Written on September 29, 2015