Wednesday, December 2, 2009
Final Prototype
Our final proposal is a system that responds to human voice or sound installed in small spaces such as elevators. Here is what we've done:
1. We bought this microphone -
http://www.sparkfun.com/commerce/product_info.php?products_id=8669
2. We searched for similar projects online and here are the scripts we found and our comments on results:
1.int pinMode(potPin, INPUT);int potpin = 2void setup() // run once, when the sketch starts{ Serial.begin(9600); // opens serial port, sets data rate to 9600 bps pinMode(potPin, INPUT);} void loop() // run over and over again{ Serial.println(analogRead(ledPin));} Result: the value does not change on the bottom of the screen.2.int potpin = 2void setup() // run once, when the sketch starts{ Serial.begin(9600); // opens serial port, sets data rate to 9600 bps digitalWrite(potPin+14,LOW); // make sure that pull up resistor is disabled -- this is usually not necessary pinMode(potPin+14, INPUT); // set input mode for ADC pin potPin -- this is usually not necessary} void loop() // run over and over again{ Serial.println(analogRead(potPin));}Result: no changes3.int ledPin = 13;int potPin = 2; // connected to speaker output pcint val = 0; // variable to store the value coming from the sensor void setup() { pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT} void loop() { val = analogRead(potPin); // read the value from the sensor or audio input digitalWrite(ledPin, HIGH); delay(val); digitalWrite(ledPin, LOW); delay(val); // stop the program for some time}Result: after modifying the script slightly we see the led respond to loud noise, but the led stays on and blinks even if no noise is made. Tried to modify the script further, no changes.4.int ledPin = 13;int potPin = 2; // connected to speaker output pcint val = 0; // variable to store the value coming from the sensorint avg = 0;void setup() { pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT pinMode(potPin, INPUT);} void loop() { val = analogRead(potPin); // read the value from the sensor or audio input avg = (avg * 127L + val) / 128; // *duck* i dont know what kind of average this is... :-) digitalWrite(ledPin, avg > 100 ? HIGH : LOW); // use lower border for more HIGH-time delay(10); // use lower delay, if it doesnt flicker enough}Result: no changes
Labels: K.A.A.S., Living Architecture, Pratt, Responsive Architecture
Post a Comment