I decided not to fly out for Thanksgiving and instead work on my Physical Computing final project. I initially started out Thanksgiving by going through the Muppet Show episodes and getting the Open CV code to work.
My classmate Adria Navarro-Lopez suggested to use the OpenCV library instead of the Open Kinect to make things easier but sadly it was not. I got help from Lisa Park on installing the library and went to work. I got the OpenCV library to detect faces using the example of detecting faces and went through the code and send it out to the arduino via serial.
Processing code for face detection for some reason it only works on Processing 2.0a1 and not 2.0a4:
import processing.serial.;
import hypermedia.video.;
import java.awt.Rectangle;
Serial myPort;
OpenCV opencv;
// contrast/brightness values
int contrastvalue = 0;
int brightnessvalue = 0;
String facesFound [];
void setup() {
size(320, 240);
println(Serial.list());
// String portName = Serial.list()[0];
myPort = new Serial(this, Serial.list()[0], 9600);
opencv = new OpenCV(this);
opencv.capture(width, height);
opencv.cascade( OpenCV.CASCADEFRONTALFACEALT );
}
public void stop() {
opencv.stop();
super.stop();
}
void draw() {
// grab a new frame
// and convert to gray
opencv.read();
opencv.convert( GRAY );
opencv.contrast( contrastvalue );
opencv.brightness( brightnessvalue );
// proceed detection
Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAARDOCANNY_PRUNING, 40, 40 );
// display the image
image( opencv.image(), 0, 0 );
// draw face area(s)
noFill();
stroke(255, 0, 0);
for ( int i=0; i<faces.length; i++ ) {
rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height );
}
//count number of faces and send to arduino
println(faces.length);
//facesFound=faces.length;
// myPort.write(facesFound);
myPort.write(faces.length);
}
/*
Changes contrast/brigthness values
*/
void mouseDragged() {
contrastvalue = (int) map( mouseX, 0, width, -128, 128 );
brightnessvalue = (int) map( mouseY, 0, width, -128, 128 );
}
The main problem I encountered was stabilizing the response of the arduino, The LED would flicker in response and not exactly the way I wanted. But the code was running the way I wanted it. It was the same problem my media controller group had encounted with the blue LED.
Arduino code for receiving:
//arduino code for lantern
//Melissa dela Merced mdm532@nyu.edu
const int bluePin=11;
const int greenPin=10;
const int whitePin=9;
const int yellowPin= 6;
const int redPin= 5;
int value = 0;
void setup(){
Serial.begin(9600);
pinMode(redPin, OUTPUT); //red LED
pinMode(yellowPin, OUTPUT); //yellow LED
pinMode(whitePin,OUTPUT); // white LED
pinMode(bluePin,OUTPUT); // blue LED
pinMode(greenPin,OUTPUT);//green LED
}
void loop(){
// if (Serial.available){
int input = Serial.read();
if (input == 0);
{
digitalWrite(bluePin, LOW);
digitalWrite(redPin, LOW);
digitalWrite(yellowPin, LOW);
digitalWrite(whitePin, LOW);
digitalWrite(greenPin,LOW);
}
if (input ==1){
digitalWrite(bluePin, HIGH);
/ Serial.write(input);
for(value=0; value <=255; value++){
analogWrite(bluePin, value);
delay(10);
}/
}
/* else{
digitalWrite(bluePin, LOW);
digitalWrite(redPin, LOW);
digitalWrite(yellowPin, LOW);
digitalWrite(whitePin, LOW);
digitalWrite(greenPin,LOW);
}/
if (input ==2){
digitalWrite(bluePin,HIGH);
digitalWrite(whitePin,HIGH);
}
/else {
digitalWrite(redPin, LOW);
digitalWrite(yellowPin, LOW);
digitalWrite(whitePin, LOW);
}*/
}
void establishContact() {
while (Serial.available() <= 0) {
Serial.println(“hello”); // send a starting message
delay(300);
}
}
I’ll still work on this code next week. I probably just need a capacitor or something on the LEDs to smooth out the signals.
I took advantage of the O’Reilly book sales, I picked up a number of books, namely Making things Talk by NYU Professor Tom Igoe, Arduino Cookbook and the Making Arduino Bots and Gadgets. In between coding, I would either finish drilling the LED holes in my template and reading the three books. Insert the Steve Jobs bio by Walter Issacson for a little inspiration.
I even went through learning using the matrix if that would help.

I went through figuring the resistor array that I would have to build and found this great web site to even design the array for you.

But that didn’t help. So right before the Stanford-Notre Dame game on Saturday night, I went for the temp sensor. Using the temp sensor was stable and works like a charm. But the weather has been great today so the LED remains at the great weather reading.
In this scenario I’m using a RHT03 Humidity and Temperature Sensor from Sparkfun . The RHT03 is similar to the DHT22 sensor so I installed the library made by github user nethoncho and it releases the temperature in celcius.

More to come.
