The idea for the hacked toy is to let people understand how much time they will need to spend on taking care puppies (You can pet the toy by covering the LDR at the back of the toy). So that they will think twice before having a puppy.
The toy has 3 output devices: 2 motors, 1 speaker,
and 1 input device: button.
One of the motor is for controlling the ears to flap, while another motor is respnsible for swinging the body left and right.
-------------------------------------------------------------------------------------------------------------
During the Trails...
Before starting the third time, if the LDR is not blocked from a light source, the toy will enter a "happy mode" in which it will flap its ear 4 times. Afterward, it will wait for another 5 second to repeat the whole process again.
If not, it will then flash the LED light to indicate it enter the "sad mode". Afterward, it will ignore you for 10 second before it repeat the whole process again.
Here is a example vedio for the action:
The circuit includes a Tip 120 transistor to control the current flow to the ear motor. A MPSA13 transistor controls the current flow to the body's motor. They relay controls the direction of the ears.Fially, there are few resistors of different values and a LED light.
--------------------------------------------------------------------------------------------------------------------------
The Final Product
The final product was modified with few more outputs and refined motions. Instead of giving only 2 chance to interact with the toy to make it happy, it now has 3 chances. Which mean the attention gathering moving is increased to 4 times instead of the original 3. After entering the "happy mode", it will also play a music. As for the "sad mode", it will play another music (a section from the song "さよならの夏” (The Summer we said goodbye) to show its loneliness.
A potentiometer and a speaker is added to the circuit for the sound effect.
Here is a sample for the "happy mode":
(the music may not be heard clearly)
Here is a sample for the "sad mode":
(the music may not be heard clearly)
The Source-code for the project:
#define sensorPin A0
#define earPin 8
#define directPin 9
#define ledPin 3
#define bodyPin 7
#include "pitches.h"
int sensorValue;
#define earPin 8
#define directPin 9
#define ledPin 3
#define bodyPin 7
#include "pitches.h"
int sensorValue;
void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(3, OUTPUT);
pinMode(7, OUTPUT);
}
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(3, OUTPUT);
pinMode(7, OUTPUT);
}
void loop()
{
int sensorValue;
sensorValue = analogRead(sensorPin);
if (sensorValue >= 100)
{
int counter;
counter = 1;
digitalWrite(ledPin, LOW);
digitalWrite(earPin, LOW);
digitalWrite(bodyPin, HIGH);
while (sensorValue >= 400 && counter < 4) // Automatically activate under day light.
{
digitalWrite(earPin, HIGH);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(earPin, LOW); // Flap the ears twice to attraction attention & wait for interaction.
counter = counter + 1;
delay(5000);
sensorValue = analogRead(sensorPin);
}
if (counter < 4 && sensorValue < 400) // Cover the toy's rear LDR sensor at the back before 3 attempted attractions by the toy to enter friendly
{ // & happy mode.
digitalWrite(bodyPin, LOW);
digitalWrite(earPin, HIGH);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(earPin, LOW);
tone(5, NOTE_A3, 200);
delay(500);
tone(5, NOTE_A3, 200);
delay(500);
tone(5, NOTE_A3, 200);
delay(200);
tone(5, NOTE_B2, 200);
delay(200);
tone(5, NOTE_E5, 600);
delay(200);
counter = 0;
delay(5000);
}
if (counter >= 4) // Leave the toy alone to let it enter the lonely mode &
{ // play the song "The Summer We Said Goodbye".
digitalWrite(earPin, LOW);
digitalWrite(bodyPin, LOW);
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
// Flash the LED, then play the music.
// Refer music to sayonara_No_Natsu.ino
tone(5, NOTE_B2, 800);
delay(400);
tone(5, NOTE_G3, 2000);
delay(800);
tone(5, NOTE_B3, 800);
delay(400);
tone(5, NOTE_F3, 2000);
delay(800);
tone(5, NOTE_B3, 800);
delay(400);
tone(5, NOTE_E3, 2000);
delay(800);
tone(5, NOTE_D3, 400);
delay(400);
tone(5, NOTE_C3, 400);
delay(400);
tone(5, NOTE_D3, 2000);
delay(900);
tone(5, NOTE_G2, 800);
delay(400);
tone(5, NOTE_C3, 800);
delay(400);
tone(5, NOTE_D3, 800);
delay(400);
tone(5, NOTE_E3, 800);
delay(400);
tone(5, NOTE_B2, 800);
delay(400);
tone(5, NOTE_E3, 800);
delay(400);
tone(5, NOTE_G3, 800);
delay(400);
tone(5, NOTE_F3, 200);
delay(100);
tone(5, NOTE_G3, 200);
delay(100);
tone(5, NOTE_F3, 2000);
delay(800);
tone(5, NOTE_CS3, 800);
delay(400);
tone(5, NOTE_DS3, 2000);
delay(800);
tone(5, NOTE_E3, 400);
delay(400);
tone(5, NOTE_E3, 6000);
delay(10000);
}
}
}
{
int sensorValue;
sensorValue = analogRead(sensorPin);
if (sensorValue >= 100)
{
int counter;
counter = 1;
digitalWrite(ledPin, LOW);
digitalWrite(earPin, LOW);
digitalWrite(bodyPin, HIGH);
while (sensorValue >= 400 && counter < 4) // Automatically activate under day light.
{
digitalWrite(earPin, HIGH);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(earPin, LOW); // Flap the ears twice to attraction attention & wait for interaction.
counter = counter + 1;
delay(5000);
sensorValue = analogRead(sensorPin);
}
if (counter < 4 && sensorValue < 400) // Cover the toy's rear LDR sensor at the back before 3 attempted attractions by the toy to enter friendly
{ // & happy mode.
digitalWrite(bodyPin, LOW);
digitalWrite(earPin, HIGH);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(directPin, HIGH);
delay(200);
digitalWrite(directPin, LOW);
delay(200);
digitalWrite(earPin, LOW);
tone(5, NOTE_A3, 200);
delay(500);
tone(5, NOTE_A3, 200);
delay(500);
tone(5, NOTE_A3, 200);
delay(200);
tone(5, NOTE_B2, 200);
delay(200);
tone(5, NOTE_E5, 600);
delay(200);
counter = 0;
delay(5000);
}
if (counter >= 4) // Leave the toy alone to let it enter the lonely mode &
{ // play the song "The Summer We Said Goodbye".
digitalWrite(earPin, LOW);
digitalWrite(bodyPin, LOW);
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
// Flash the LED, then play the music.
// Refer music to sayonara_No_Natsu.ino
tone(5, NOTE_B2, 800);
delay(400);
tone(5, NOTE_G3, 2000);
delay(800);
tone(5, NOTE_B3, 800);
delay(400);
tone(5, NOTE_F3, 2000);
delay(800);
tone(5, NOTE_B3, 800);
delay(400);
tone(5, NOTE_E3, 2000);
delay(800);
tone(5, NOTE_D3, 400);
delay(400);
tone(5, NOTE_C3, 400);
delay(400);
tone(5, NOTE_D3, 2000);
delay(900);
tone(5, NOTE_G2, 800);
delay(400);
tone(5, NOTE_C3, 800);
delay(400);
tone(5, NOTE_D3, 800);
delay(400);
tone(5, NOTE_E3, 800);
delay(400);
tone(5, NOTE_B2, 800);
delay(400);
tone(5, NOTE_E3, 800);
delay(400);
tone(5, NOTE_G3, 800);
delay(400);
tone(5, NOTE_F3, 200);
delay(100);
tone(5, NOTE_G3, 200);
delay(100);
tone(5, NOTE_F3, 2000);
delay(800);
tone(5, NOTE_CS3, 800);
delay(400);
tone(5, NOTE_DS3, 2000);
delay(800);
tone(5, NOTE_E3, 400);
delay(400);
tone(5, NOTE_E3, 6000);
delay(10000);
}
}
}





No comments:
Post a Comment