Wednesday, February 14, 2007

random idea - Secret Tree

When the people confess their secrets to the tree, the secrets make the tree grow, the flowers bloom and the fruits bear. In the book “The Giving Tree” by Shel Silverstein and the movie “In the Mood for Love” by director Wong Kar Wai, the main characters confess their secrets to a tree because it never tells their secrets to other people and it always keep them as long as the tree stays alive.
The project “Secret Tree” listens, interprets and stores people’s secrets in its leaves or fruits with a unique format. Afterwards, their secret is stored in the fruit and through a speaker other people will be able to listen to these secrets in a unique and altered format.


Idea scketch


The First Prototype

Wednesday, February 07, 2007

Do as I told you!


Untie tangled strings!

Friday, February 02, 2007

microphone setup on breadboard


reference : Physical Computing - Dan O'Sullivan and Tom Igoe
Sound Input on a Microcontroller (p.356)
audio amplifier : LM386
capacitor : 220 microparads, 10 microparads, 4.7 microparads
resistor : 1kohm, 10kohm, 100kohm

microphone Arduiono code
int microPhone = 0;
int AmpVar = 0;
int micValue =0;

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

void loop() {
micVal = analogRead(microPhone);
if (micVal>=512){
AmpVar = micVal-512;
}
else {
AmpVar = 512-micVal;
}
micValue = AmpVar; // read the analog input
//Serial.println(AmpVar);
resetVal = digitalRead(resetSwitch);

if (micValue >= THRESHOLD) { // check if the input is HIGH (button released)
micCurrentState = 1;
}
else {
micCurrentState = 0;
}
//if(micCurrentState != micPreviousState){
if(micCurrentState == 1){
micCounter = micCounter + 1;
//Serial.println("micCounter = ");
//Serial.println(micCounter);
}
//}
//micPreviousState = micCurrentState;

if (micCounter > 0) {
digitalWrite(candleLEDs, LOW);
delay(100);
}

}

Happy Birthday project 1st prototype code

int firstLayerLEDs = 3;
int secondLayerLEDs = 4;

int candleVal = 0;
int candleSwitch =5;
int switchState = 0; // the state of all situation
int candleLEDs = 6;
int microPhone = 0;
int AmpVar = 0;
int micValue =0;
int micCounter = 0;
int micCurrentState = 0;
int micPreviousState = 0;

int resetVal = 0;
int resetSwitch = 7;

int micVal = 0;
int statePin = HIGH;
int THRESHOLD = 20;

int relay1 = 8; // select the realy pin for mp3 player
int relay2 = 9;
int relay3 = 10;

int firstCounter = 0;
int secondCounter = 0;
int thirdCounter =0;

void setup() {
pinMode(firstLayerLEDs, OUTPUT);
pinMode(secondLayerLEDs, OUTPUT);
pinMode(candleSwitch, INPUT);
pinMode(candleLEDs, OUTPUT);
pinMode(resetSwitch, INPUT);
pinMode(relay1, OUTPUT); // declare the relay Pin as an OUTPUT
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);

Serial.begin(9600);
}

void loop() {
candleVal = digitalRead(candleSwitch);
micVal = analogRead(microPhone);
if (micVal>=512){
AmpVar = micVal-512;
}
else {
AmpVar = 512-micVal;
}
micValue = AmpVar; // read the analog input
//Serial.println(AmpVar);
resetVal = digitalRead(resetSwitch);

if (micValue >= THRESHOLD) { // check if the input is HIGH (button released)
micCurrentState = 1;
}
else {
micCurrentState = 0;
}
//if(micCurrentState != micPreviousState){
if(micCurrentState == 1){
micCounter = micCounter + 1;
//Serial.println("micCounter = ");
//Serial.println(micCounter);
}
//}
//micPreviousState = micCurrentState;



if (switchState == 0) {
thirdCounter = 0;
secondCounter =0;
firstCounter= firstCounter + 1;
if (firstCounter == 1){
digitalWrite(relay1,HIGH);
delay (500);
digitalWrite(relay1, LOW);
//delay (500);
//digitalWrite(relay3,HIGH);
//delay (500);
//digitalWrite(relay3, LOW);
//delay (3000);
Serial.println("relay2 & relay3, each was pressed once");
}

digitalWrite(firstLayerLEDs, HIGH);
digitalWrite(secondLayerLEDs, HIGH);
digitalWrite(candleLEDs, LOW);
delay(100);
}
//if (candleVal == HIGH && micValue < THRESHOLD) {
if (candleVal == HIGH && micCounter == 0) {
switchState = 1;

}
if (switchState == 1) {
firstCounter =0;
thirdCounter =0;
secondCounter= secondCounter + 1;
if (secondCounter == 1){
digitalWrite(relay1,HIGH);
delay (500);
digitalWrite(relay1, LOW);
//delay (3000);
Serial.println("relay2 was pressed onece");
}

digitalWrite(firstLayerLEDs, HIGH);
digitalWrite(secondLayerLEDs, HIGH);
digitalWrite(candleLEDs, HIGH);
delay(100);
digitalWrite(firstLayerLEDs, HIGH);
digitalWrite(secondLayerLEDs, HIGH);
digitalWrite(candleLEDs, HIGH);
delay(100);
}
//comment your code!
if (candleVal == HIGH && micCounter > 0) {
switchState = 2;
}
if (switchState == 2) {
firstCounter = 0;
secondCounter = 0;
thirdCounter= thirdCounter + 1;
if (thirdCounter == 1){
digitalWrite(relay1,HIGH);
delay (500);
digitalWrite(relay1, LOW);
//delay (3000);
Serial.println("relay1 was pressed once");
}

digitalWrite(firstLayerLEDs, LOW);
digitalWrite(secondLayerLEDs, LOW);
digitalWrite(candleLEDs, LOW);
delay(100);
}


//if (resetVal == 0) {
//if (resetVal == 0 || candleVal == LOW) {
if (candleVal == LOW) {
switchState = 0;
micCounter = 0;
}
}


/*
when the cake is built all lights are on

when the candle is blown all lightw go off

*/

Happy Birthday project 1st prototype picture and movie





Happy Birthday project prototype picture and video




Happy Birthday project prototype code without mp3 function

int firstLayerLEDs = 3;
int secondLayerLEDs = 4;

int candleVal = 0;
int candleSwitch = 5;
int switchState = 0; // the state of all situation
int candleLEDs = 6;
int microPhone = 0;
int AmpVar = 0;
int micValue =0;
int micCounter = 0;
int micCurrentState = 0;
int micPreviousState = 0;

int resetVal = 0;
int resetSwitch = 7;

int micVal = 0;
int statePin = HIGH;
int THRESHOLD = 100;

void setup() {
pinMode(firstLayerLEDs, OUTPUT);
pinMode(secondLayerLEDs, OUTPUT);
pinMode(candleSwitch, INPUT);
pinMode(candleLEDs, OUTPUT);
pinMode(resetSwitch, INPUT);

Serial.begin(9600);
}

void loop() {
candleVal = digitalRead(candleSwitch);
micVal = analogRead(microPhone);
if (micVal>=512){
AmpVar = micVal-512;
}
else {
AmpVar = 512-micVal;
}
micValue = AmpVar; // read the analog input
Serial.println(AmpVar);
resetVal = digitalRead(resetSwitch);

if (micValue >= THRESHOLD) { // check if the input is HIGH (button released)
micCurrentState = 1;
}
else {
micCurrentState = 0;
}
//if(micCurrentState != micPreviousState){
if(micCurrentState == 1){
micCounter = micCounter + 1;
Serial.print("micCounter = ");
Serial.println(micCounter);
}
//}
//micPreviousState = micCurrentState;



if (switchState == 0) {
digitalWrite(firstLayerLEDs, HIGH);
digitalWrite(secondLayerLEDs, HIGH);
digitalWrite(candleLEDs, LOW);
delay(100);
}
//if (candleVal == HIGH && micValue < THRESHOLD) {
if (candleVal == HIGH && micCounter == 0) {
switchState = 1;
}
if (switchState == 1) {
digitalWrite(firstLayerLEDs, HIGH);
digitalWrite(secondLayerLEDs, HIGH);
digitalWrite(candleLEDs, HIGH);
delay(100);
digitalWrite(firstLayerLEDs, HIGH);
digitalWrite(secondLayerLEDs, HIGH);
digitalWrite(candleLEDs, HIGH);
delay(100);


}
//comment your code!
if (candleVal == HIGH && micCounter > 0) {
switchState = 2;
}
if (switchState == 2) {
digitalWrite(firstLayerLEDs, LOW);
digitalWrite(secondLayerLEDs, LOW);
digitalWrite(candleLEDs, LOW);
delay(100);
}


//if (resetVal == 0) {
if (resetVal == 0 || candleVal == LOW) {
switchState = 0;
micCounter = 0;
}
}


/*
when the cake is built all lights are on

when the candle is blown all lightw go off

*/