Project #2: hybrid interaction

For the hybrid interaction project I  was tasked with creating 3 analogue inputs and 3 outputs on the Arduino Uno circuit board. My initial design was supposed to be a light sensor lock that unlocks when you shine a flashlight on the photo resistor sensor. Sadly i was a bit ambitious in my design and idea. I broke this down to a much more rudimentary device so that I could fulfill as much of the assignment as possible.

I have one photo resistor that measures the amount of light that is hitting it, When the light changes and hits 1069 it will finish the circuit and allow the servo or motor to turn the lock open. For the assignment I added an LED light and a pezio speaker sensor to the circuit that change in brightness and loudness has the photo resistor receives less light. With the servo motor i have also used a capacity sensor. You also have to turn the servo back every time for it to work correctly. (need some more time to code this in but it will have to do)

The code game me the most hassle because although i wrote it with the intention of having three photo resistor inputs, i could not figure out how to make more than one void setup / void loop. I figured later that i could use the #include tag and put the codes in different windows. (this was rushed but it will do)

IMG_20140228_182833

IMG_20140228_182925

My motor broke so i found a way to connect to female pins to make a longer one so my servo could fit into the board.

IMG_20140228_190045

IMG_20140228_190058

#include <Servo.h>

Servo servo1;

int photocellPin = A0; // the cell and 10K pulldown are connected to a0
int photocellPin2 = 11;
int photocellPin3 = 12;
int photocellReading; // the analog reading from the sensor divider
int LEDpin = A1; // connect Red LED to pin 11 (PWM pin)
int LEDbrightness; //
int servoPin = A0; // connect servo to pin 10
int pos = 0;
int speakerPin = A2; // connect speaker to pin 9
int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;

const int ledPin = 13;

void setup() {
// We’ll send debugging information via the Serial monitor
Serial.begin(9600);
servo1.attach(10);

pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);

while (millis() < 5000) {

sensorValue = analogRead(A0);
if (sensorHigh) {
sensorHigh = sensorValue;
}
if (sensorValue < sensorLow)  {
sensorLow = sensorValue;
}
}
digitalWrite(ledPin, LOW);

}

void loop(void) {

photocellReading = analogRead(photocellPin);

Serial.print(“Analog reading = “);
Serial.println(photocellReading); // the raw analog reading
// LED gets brighter the darker it is at the sensor
// that means we have to -invert- the reading from 0-1023 back to 1023-0

Serial.print(“Cell = “);
Serial.println(analogRead(A0)); // the raw analog reading servo

pos = analogRead(photocellPin);
pos = constrain (pos, 220, 740);

photocellReading = 1023 – photocellReading;
//now we have to map 0-1023 to 0-255 since thats the range analogWrite uses
LEDbrightness = map(photocellReading, 0, 1023, 0, 255);
analogWrite(LEDpin, LEDbrightness);

sensorValue = analogRead(A2);
int pitch =
map(sensorValue, sensorLow, sensorHigh, 200, 4000);

tone(8, pitch, 20);

delay(100);
}

 

VID_20140228_185946

no sound but the speaker should changed every time the LED changes brightness and the servo moves.

fritzing diagram hybridFitzing diagram

4 thoughts on “Project #2: hybrid interaction

  1. I still remember I had so much problem doing my ardunio project I really like your project.You have some awesome images of your project.I wish I was in class on the due date,so I could have seen your project in class.Good job

  2. I still remember I had so much problem doing my ardunio project I really like your project.You have some awesome images of your project.I wish I was in class on the due date,so I could have seen your project in class.Good job

  3. Hey Kirk,
    Thought it was a great idea, I also like that it is practical. I think that you have definitely used an awesome method for your lock and its great that you supplied the code cause I’d love to swap some of it into mine and try some new things. And great problem solving skills for putting those 3 inputs in, I would have never thought of using another window.

    Antonio

  4. Pingback: Blog Entries on other’s site | Hamza's Blog

Leave a comment