Back to Parent

Outcome


Meet Marcel. Isn't he cute?????

Img 20170201 210855
Show Advanced Options

Like many cats, Marcel stays home alone for most of the day while the humans are away. Most cats like to play with interactive toys, and most cats grow bored without any stimulation during the day. The goal of this connected device is to detect movement when the cat walks by, and then trigger a servo motor to move a stick with an attached string  in a compelling motion for Marcel to play with.

Components: This project will require the following materials

Particle microcontroller

Breadboard

PIR Motion Sensor

Servo motor

Toy assembly, mounted to servo

LED

Misc. resistors and wiring

Process:

First step was setting up the PIR sensor.  I first wired the PIR motion sensor as well as an LED so that I could get feedback on how the PIR sensor was working. I input some simple code to light up the LED if the sensor was triggered. After confirming that the Particle was receiving a signal from the PIR, it seemed to be a constant signal unless the PIR was completed covered up. To prevent the PIR from triggering due to ambient light and movement, I put the sensor inside a toilet paper roll (upcycling!). This solved the issue, and the sensor was only triggered when I wave my hand directly in front of the roll. 

Next came the servo. I wired in the servo and input basic servo code that controlled from a cloud function so that I could confirm the servo was wired correctly (see Sources). The full circuit diagram can be found at the end of the post.  

Next, I needed to tie together the PIR trigger and the servo movement. Daragh helped me to implement a counter to instruct the servo how long to run after the trigger. I also "randomized" the movement of the servo by inputing a random number as the servo position. See full code below. 

Finally, I used IFTTT to populate a spreadsheet, in case I theoretically wanted to know how many times the toy was being set off. I published an event whenever the sensor was triggered (Particle.publish(''catmotion"), and created an applet to populate a spreadsheet in google drive. 

Slide2
Show Advanced Options

This picture shows the completed circuit after finished the code, before assembling with the cat toy. 

Outcome:

To assemble the prototype, I attached the cat toy, a stick and string assembly, to the servo motor. I mounted the servo and the sensor/toilet roll assembly to a bookshelf. After initial testing, I realized that the sensor would have to be pointed out of range of the moving cat toy, otherwise it would continue on forever. I moved the sensor assembly to the wall. Once everything was attached, it worked great. 

Marcel was initially intrigued by the moving string, but I think he was also a little startled by the jerky movement and sound of the servo. I could keep working on a servo movement sequence that most appealed to him. See pictures and video below!

(Continue scrolling to find Reflections and Sources)

Img 20170201 205955
Show Advanced Options
Show Advanced Options
Show Advanced Options

Reflection:

This project seemed difficult and intimidating to begin with, but after completing the planning phase and thinking about the required components for the circuit, I felt more confident. Putting together the circuit from various Hackster projects was no problem. I learned a lot from putting together the code and integrating a counter. Overall, it was a fun project and is a good place to start in the world of hacking and IoT!

Sources:

For wiring and coding the PIR, I got started from the following sources:

https://particle.hackster.io/dog-squad/time-to-take-the-dog-out-04f7a7?ref=search&ref_id=pet&offset=1

https://www.hackster.io/falafel-software/pir-sensor-with-a-photon-particle-cloud-and-a-uwa-97e79b

The following project merged a PIR as well as a servo and was very helpful in getting started with the servo code:

https://particle.hackster.io/team-sjw/diy-home-motion-sensor-light-1c66f1?ref=search&ref_id=pet&offset=6

I was inspired by the following source but did not end up using any of the code or circuits:

https://particle.hackster.io/jacob-tucker/cat-caddie-3cb886?ref=search&ref_id=pet&offset=3

For my counter, I adapted code from Daragh Byrne.

Untitled sketch 2 bb
Show Advanced Options
Show Advanced Options
Drop files here or click to select

You can upload files of up to 20MB using this form.