Making Things Interactive

March 9, 2008

Midterm: Visual LED Sound Meter

Filed under: 7: Mid-Term Project, Jesse Chorng — Jesse @ 10:37 pm

As you recall from my midterm proposal, the goal of my project was to add functionality to an existing SURG grant. I wanted to focus on three things that would make Boomboxes (see here to refresh your memory) more conducive to social interaction. By utilizing the Arduino, I wanted to add visual, audio, and communication to the mp3 space so that it could be more than just a set of speakers and really encourage social activities. The most successful part of my midterm was the completion of a visual representation of the music. Looking back, it was much easier than I had made it out to be. But in order to do this, it required that I learn a lot about integrated circuits, particularly the LM3915 dot/bar display driver and the LM741 op amp chips. I had planed to use the LM741 op amp to boost the line in audio signal but found out later that it wasn’t really necessary (after hours of trying to wire it all out)  There are various schematics available online about how to use the LM3915 to drive 10 LEDs to act as a 30 db volume meter.

I ended up using one different from the schematic I originally drew for the proposal seen below.

For the audio input, I was trying to get PodGizmo’s iPod breakout board to function using other people’s work on getting functionality through the iPod dock connector. The pinout is exceptionally useful and allowed me to see what each of the 30 connectors in the iPod dock does. However, there is limited work still underway to try and figure out how exactly the iPod dock connector functions and a lot of it still remains a mystery.  I was unable to grab audio from the iPod dock connector for an unknown reason and had to use a 1/8″ stereo headphone cable instead. I suspect that pin 21 in the iPod dock has something to do with setting the iPod in the proper mode. When not in proper state, the iPod continued to output music only thru the headphone jack and not the dock connector. I will continue to work with it and update this post as soon as I get a better understanding of the iPod Accessory Protocol. 

Here is a short video of my meter in action: 

The Arduino code I used was very very basic because working with ICs became my main focus. On the Arduino side all I wanted it to do was detect when music was being played and at what level. Since the music outputs a 0 – 1.5V signal, all I did was read that and print it out on the display.

/* iPod Analog Read*/

int ipodPin = 2;       // sets analog input pin from iPod audio out
int val = 0;            // variable to store the value coming from audio out

void setup(){
     Serial.begin (9600);
}

void loop(){
     val = analogRead(ipodPin); 
     Serial.print(' The iPod input is: ');
     Serial.print(val);
     Serial.println( V);
} 

NoseTouch Sensor

Filed under: 7: Mid-Term Project, Joshua Smith — jssmith44 @ 8:29 pm

For this project I created a system that follows an individual when in the camera’s field of vision, and detects when the user touches his/her nose. Video is displayed below: The project consists of a Processing application (processing.org), an Arduino application (arduino.cc), and a hardware component.  The computer vision component is processed in the Processing application and the user’s physical location and state (nose touch or no touch) is passed to the Arduino application which drives the hardware.   The following Processing code uses the OpenCV framwork (http://www.intel.com/technology/computing/opencv/) and the Face Detect Library for Processing by Jaegon Lee (http://tokage.cafe24.com/facedetect/)  

import FaceDetect.*;
import processing.serial.*;  

FaceDetect fd;
Serial port;

int viewingAngle = 75;  //Camera's Viewing Angle
int MAX = 4;            // Max number of faces detected at once (for game)
int sPosition = 90;     //servo starting position

int[] x = new int[MAX];
int[] y = new int[MAX];
int[] r = new int[MAX];
int[][] Faces = new int[MAX][3];

void setup(){

  size(640,480);
  fd = new FaceDetect();
  fd.start(width,height, 10);
  println(fd.version()); 

  noStroke();
  println(Serial.list()); // List COM-ports

  //select second com-port from the list
  port = new Serial(this, Serial.list()[0], 19200);
}

void draw(){
  background(0);

  Faces = fd.detect();
  int count = Faces.length;

  if (count>0) {
    for (int i = 0;i<count;i++) {
      x[i] = Faces[i][0];
      y[i] = Faces[i][1];
      r[i] = Faces[i][2] * 2;
 println(i+1 + ": " + x[i]+", "+y[i] + ", " + r[i]);

  int divider = (width)/viewingAngle;
  int sPosition= x[i]/divider;  //Calculate servo postion from Face X Coordinate
  sPosition = sPosition - (sPosition%1);

  //Output the servo position ( from 0 to ViewingAngle)
  port.write("s"+sPosition); 

    }

  }

  int[] img = fd.image();
  loadPixels();
  arraycopy(img,pixels);
  updatePixels();

 if (count == 0)  //identifies nose touch (no faces recognized)
    {port.write("w");
   delay(250); }

  strokeWeight(2);
  stroke(255,200,0);
  noFill();
  for(int i =0;i<count;i++) {
    ellipse(x[i],y[i],r[i],r[i]);
  }

}

public void stop(){
  fd.stop();
  super.stop();
}

  The Arduino code to communicate with the processing code and drive the servo motor and LED eyeball: (note this code requires installation of the Arduino “Servo” library)  

#include
Servo servo1;
int ledPin = 13;

void setup() {
  servo1.attach(14);
  servo1.setMaximumPulse(2500);
  Serial.begin(19200);
  Serial.print("Ready");
}
void loop() {
  static int v = 0;
  if ( Serial.available()) {
    char ch = Serial.read();
    switch(ch) {
      case '0'...'9':
        v = v * 10 + ch - '0';
        break;
      case 's':
        servo1.write(v);
        v = 0;
        break;

      case 'w':
      blink();
      v = 0;

    }
  } 

 Servo::refresh();
}

void blink(){
  digitalWrite(ledPin, HIGH);   // sets the LED on
      delay(100);                  // waits for .1 second
      digitalWrite(ledPin, LOW);    // sets the LED off
      delay(100);                  // waits for .1 second
    }

(the include file should be “Servo.H”, but I cant get it to show up in the sourecode editor)

Finally, the hardware component consisted of just an aluminum rod, rubber eyeball, red LED, and a servo motor. The Servo motor was connected directly to the Arduino board in the following manner: Orange: 5V; Black: Ground; Yellow: Analog Input 0;
The Led was connected to Ground and Digital Pin 13.  

Blog at WordPress.com.