As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Tuesday, June 11, 2013

Sensor experimentation [Maddie and Candice ]

Based on the design situation we wanted to pursue, we were happy to read about a motion sensor that was pretty cheap and easily accessible (at RadioShack on the Ave, yay!). We looked online for codes that would work for our situation, and what we found was code that made a Nikon D80 take a picture when motion was detected from a PIR.

This is how the system worked:
1. Motion is detected from the Parallax PIR sensor
2. The Infrared (IR) LED lights up (as can be monitored by a regular LED lighting up as well)
3. The IR sensor on the camera detects the waveform from the IR LED light
4. IR sensor triggers the shutter on the Nikon D80
5. A picture is taken


We found the code from someone on the intertubes called Steven Holland (http://stratigrafia.org/blog/entries/2012-09-01.html), who customized their code from someone else.

// Based on http://luckylarry.co.uk/arduino-projects/arduino-motion-triggered-camera/
// The sequence of pulses needed appears to have been reverse engineered at http://www.bigmike.it/ircontrol/
// This is another useful site on the subject: http://www.bemasher.net/archives/114

int pirPin = 4; // digital pin 4 for PIR; put a 10k Ohm resistor between pin 4 and OUT on PIR
int ledPin = 13; // digital pin 13 for LED; put a 220 Ohm resistor between pin 13 and the LED
int IRPin = 2; // assign the Infrared emitter/ diode to pin 2; connect other lead of IR diode into ground
int noMotion = 1;

// pulse the infrared emitter for a specified duration (in microseconds)
void pulseON(int pulseDuration) {
unsigned long endPulse = micros() + pulseDuration; // calculate time when pulse should stop
int halfCycle = 13; // half a clock cycle for a 38 Khz (26.32 microseconds period) wave
while(micros() < endPulse) {
digitalWrite(IRPin, HIGH); // emit IR for half a cycle
delayMicroseconds(halfCycle);
digitalWrite(IRPin, LOW); // stop emitting for half a cycle
delayMicroseconds(halfCycle);
}
}

// stop pulsing the infrared emitter for a specified duration (in microseconds)
void pulseOFF(unsigned long delayDuration) {
unsigned long endDelay = micros() + delayDuration; // calculate time when delay is over
while(micros() < endDelay);
}

// sequence of pulses for taking a picture on a Nikon D80 camera
void takePicture() {
for (int i=0; i<2; i++) {
pulseON(2000); // pulse for 2000 microseconds,
pulseOFF(27850); // then off for 27850 microseconds,
pulseON(390); // on for 390 microseconds, and so on
pulseOFF(1580);
pulseON(410);
pulseOFF(3580);
pulseON(400);
pulseOFF(63200);
} // loop the signal twice.
}

void setup() {
pinMode(pirPin, INPUT); // set PIR pin as input
pinMode(ledPin, OUTPUT); // set LED pin as output
pinMode(IRPin, OUTPUT); // set pin as output
}

void loop() {
if(digitalRead(pirPin) == HIGH) {
// motion detected
if (noMotion == 0) {
// take picture only if coming from a state of no motion
digitalWrite(ledPin, HIGH);
takePicture();
noMotion=1;
delay(5000); // wait 5 seconds between pictures
}
} else if(digitalRead(pirPin) == LOW) {
// No motion
digitalWrite(ledPin, LOW);
noMotion=0;
}
}

We found all the components we needed for this experiment on RadioShack, with the exception of the Arduino board and breadboard, which we bought online at Amazon.

- An Arduino board
- A small breadboard
- Parallax PIR sensor #555-28027-RT
- Infrared LED, such as Radio Shack 276-0143
- An LED
- A 220 Ω resistor
- A 10 kΩ resistor
- 22-gauge wire jumpers


No comments:

Post a Comment