Interacting with Cat
Abstract
Reason of doing this final project is that many people would like to have a pet but because of the reasons like allergic or not permitted by parents, they cannot own one. Meanwhile, cat is a kind of pet that commonly seen. Thus we want to create a work with which people can have simple interactions with cat.
Logic Design for Interaction
Logical relationship one: Cat is afraid of people, therefore when people get closer to the cat, the cat will hide in the cat bag.
Logical relationship two: Cat is afraid of people, so when people get further from the cat, cat will come out from the bag.
Logical relationship three: Cat may think people harmless when food is given to them, thus when people get closer but give food, cat will also come out to get the food.
Inputs
According to the logic design, ultrasonic sensor and button are used as input of our project to transfer the physical data of distances into digital data, and further generate some interaction between people and the “cat” on the screen.
Theory - the Doppler Principle
Ultrasonic sensors mainly use Doppler Principle. The crystal vibrates to emit high-frequency ultrasonic waves beyond human perception. If there is a motion in the region, the reflected wave frequency will fluctuate slightly, that is, the Doppler effect. In this way, objects in the lighting area can be judged to move, so as to achieve the purpose of controlling the switch.
Codes
Because there are two input devices of our project, we have to define them in the codes of Arduino. First is identifying the signals from two devices, so two pin modes are setup as shown in the image. Next is calculating the distance of the people and the sensor. Distance is the time in microseconds from the sending of the EchoPin to the reception of its echo of an object, whose counting unit is centimeter. Then there are two algorithms which can get rid of the first data and the largest data from the five distances we detected, so that the program can send a relatively accurate data to Processing.
To interact with the “cat”, which is actually in the videos, the three videos associated with the three logics are inserted in Processing to be run. Then, the data sent from Arduino gained by the two input devices are transferred to Processing.
Next is distinguishing the three probabilities to generate three results: When the distance is more than 80cm, and the button is not pressed, it means “people is/are away”, the result of “NewCMDFlag=1” will be presented; when the distance is shorter than 80cm, and the button is not pressed, it means “people get close”, the result of “NewCMDFlag=2” will be presented; when the distance is shorter than 80cm, and the button is pressed, it means “people get close, but feed”, the result of “NewCMDFlag=3” will be presented.
The three results are linked with the three videos inserted at the beginning of the codes, so the following steps are just play the specific ones in the certain situations. And the last step is to stop the videos.