The final plant-pet
The Plant pet was a device and toy that helps people to control their emotion and stress by raising experience. Depending on care(touching a leaf), it can make a growth and dancing. It needs 9 times the number of touching for half inches growth.
<< Plant pet shapes>>
For the final work, I made different color structure. I didn’t like to choose green
color because of the reason it is a plant. However, because shape of the plant pet is now more like cute toys, so, I chose the green one rather than other color.
This is the final work with two motors for growth and dancing.
<<The final mechanism >>
By using the second motor for dancing, I had to install the second motor on the top of the lever. As Tom recommends the position, I would put the second motor the effort side rather than load side of the lever. And, for the balancing the lever and coming down the wire which regulate the height, I put the spring below the lever.
Now, depending on the touching time, the plant pet makes the growth and then if it’s grown up, it makes dancing by people’s touch.

<<Code for controlling two motor by concept>>
int analogValue; // values from a sensor
int analogPin; // pin 0
int count =0; // whenever coming to the first value, count
int countForServo; // whenever count be the odd, another counter count
long currentTimeValue = 0; // values for checking time when values comes
boolean touched = false; // values for whether it’s touched or not
int servoPin1 = 3 ;
int servoPin2 = 9; // analog output pin
int refreshTime = 20; // 20msec for servo
int i=0;
int miniPulse = 600; // miniPulse
int maxPulse = 2400; //maxpulse
int servoPulse1 = miniPulse; // put the minipulse into the servoPulse
int servoPulse2 = miniPulse;
long lastPulse1 = 0; //
long lastPulse2 =0;
int servoSpeed =1;
int servoSpeed2 = 50;
int tempPulse;
void setup(){
Serial.begin(9600);
pinMode(servoPin1,OUTPUT);
pinMode(servoPin2,OUTPUT);
}
void loop(){
analogValue = analogRead(analogPin); // anaogread
// if I get the analogvalue and the first value , count
if(analogValue > 20 && touched == false){ // if anaogValue comes in and touched was not changed yet(first value)
count++; // counting
currentTimeValue = millis();
if(count % 1 == 0){
countForServo++;
}
touched=true;
}else if (analogValue <= 20){
touched = false; }
// output depending on how many times i touch sensor
// analogWrite(blinkPin, servoPulse); // analog write if(countForServo >2){ // countforservo becomes over 3
if(servoPulse1 < maxPulse){ // until the pulse become 2400
servoPulse1 += 50; // add 50 and sum up
refreshServo();
}
countForServo = 0; // if countforled become over 3, count become 0
}
if (servoPulse1 >= maxPulse){ // if brightness become over 2400,
servoPulse1 = maxPulse; // brightness become 2400
refreshServo();
tempPulse++;
if(servoPulse1 == maxPulse && tempPulse <30000){
makeServo();
}
else{
tempPulse =0;
}
count =0; // make the count zero
}
if( millis() - currentTimeValue > 3000){ // if it has not gotten any value 3 seconds later from currentTimeValue,
if(servoPulse1 > miniPulse){ // substract 5 and sum up
servoPulse1 -= 5;
refreshServo();
}
if(servoPulse1 <=miniPulse){ // if servoValue becomes below 600
servoPulse1 = miniPulse; // value becomes 600
}
}
// print all values
Serial.print(” analogValue : “);
Serial.print(analogValue);
Serial.print(” count : “);
Serial.print(count);
Serial.print(” countForServo : “);
Serial.print(countForServo);
Serial.print(” servoPulse1 : “);
Serial.print(servoPulse1);
Serial.print(” servoPulse2 : “);
Serial.print(servoPulse2);
Serial.print(” currentTimeValue : “);
Serial.print(currentTimeValue);
Serial.print(” millis : “);
Serial.println(millis());
}
void refreshServo(){
if(millis() - lastPulse1 > 20){
digitalWrite(servoPin1,HIGH);
delayMicroseconds(servoPulse1);
digitalWrite(servoPin1,LOW);
lastPulse1 = millis();
}
}
void makeServo(){
if(millis() - lastPulse2 > 20){
digitalWrite(servoPin2,HIGH);
delayMicroseconds(servoPulse2);
digitalWrite(servoPin2,LOW);
lastPulse2 = millis();
}
servoPulse2 += servoSpeed2;
if(servoPulse2 >=2000){
servoPulse2 = 2000;
servoSpeed2 = -100;
}
if(servoPulse2 < 800){
servoPulse2 = 800;
servoSpeed2 = 100;
}
}