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.

Wednesday, May 8, 2013

Randy & Charlie: Microphone

We got our electret microphone to work going off of this schematic: http://www.dtic.upf.edu/~jlozano/interfaces/microphone.html. However it barely picks up any sound at all. We think it's a problem with the op-amp.


/*
  AnalogReadSerial
  Reads an analog input on pin 0, prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
 
 This example code is in the public domain.
 */

int vibrationPin = 9;
long strength, data;
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  pinMode(vibrationPin, OUTPUT); 
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  float sensorValue = (float)analogRead(A0);
  // print out the value you read:
  
  strength = (long)voltageToHertz(sensorValue);
  data = (long)voltageToByte(sensorValue);
  Serial.println(sensorValue);
  tone(vibrationPin, strength, 100);
//  String value = String(sensorValue);
//  Serial.write(value);
  delay(2);        // delay in between reads for stability
}

float voltageToHertz(long volts) {
  long value = (float)(180 * ((float)volts / (float)1024));
  if (value > 20) {
    return value;
  } else {
    return 0;
  }
}

float voltageToByte(long volts) {
  long value = (float)(255 * ((float)volts / (float)1024));
  if (value > 20) {
    return value;
  } else {
    return 0;
  }
} 

No comments:

Post a Comment