Introduction: Get Off the Couch, With Arduino, 3d Printed Enclosure and Programmed With Embrio

The basic Idea is to create something that can detect when my dogs get on the couch when I'm not there and "encourage them to get off". This is accomplished with A Passive Ifrared sensor, and making noises that the dogs don't like.

I saw another similar project that used a child's toy but I wanted to make something completely with an Arduino and 3d printing, and using Embrio to program the Arduino. So this is what I came up with.

Basically a PIR sensor (like used in alarm systems) detects motion on the couch area and turns on a noise maker thus scaring the dogs off the couch.

Let's start with the Fio,

This is another Arduino based board. The reasons I chose it are

1) it's small
2) It's inexpensive
3) it runs on rechargeable lipo battery and has built in charger

This is great for little projects that you don't want to plug in, I had started to use Adafruit's Trinket which are SUPER cheap ATtiny boards much like Arduino and since this project didn't need the more pins it was a good choice and I have a few of them and they are great for small projects, but when I started adding the battery charger etc, well I'm lazy and looked further and found these boards.

Step 1: Making Desicions

Ok so I planned this out on paper first, and my first idea was to use a piezo speaker and a little vibration motor. First test run it just wasn't loud enough. So I had to rethink this part. I ended up designing something using an idea from a New Years Eve noise maker I've seen that is just a gear and a plastic reed that you swing around.

I happen to have a nice 3v DC motor around in the scrap pile So I used that. If you want to be able to use my design as is you can try to find one of these motors, they are common in CD Drives and can be found on Ebay (mitsumi m25e-4). Second lesson learned here was that while this motor runs well on 3v running it directly from the data pin on the Arduino did not give enough amps to have any strength, So I will show you how to use an NPN transistor to pull power directly from the source and trigger it with the pin instead.

Lets Start with the PIR.

PIR stands for Passive InfraRed sensor, This sensor has two halves that look at the infrared in and compare the two halves, if they are different the senor's data pin goes HIGH, which means there is a positive voltage on it. This we connect to our Arduino data pin 3. The VCC and GND go to the 3.3 volt and gnd on the Duino.

My little motor just has two leads RED and BLACK the black we connect to the ground The RED if we apply 3v power the motor will spin so what we do is use a NPN transistor as a switch.

NPN transistor as a switch is very useful, the NPN has three legs, when looking at the flat edge they are from right to left Emitter, Base and Collector, if you apply a very small voltage to the Base connector then voltage will flow through the Emitter and Collector, so we attach the Base to our Duino on PIN 6 we then connect the Emitter to 3.3 volt directly to the battery, I connected on the underside of the Duino where it's labeled Batt +. Then the collector is attached to the positive lead of the motor, Then when the arduino pin 6 is HIGH (+3v) power will flow from the battery to the motor.

We basically do the same with the Pizeo buzzer but to Pin 7.

There was so little wiring that I just wired the transistors directly in line.

Step 2: FIO

The Arduino fio is a very small Arduino that has built in Battery charger and connection for lipo battery which makes it a great choice for this sort of project. I'm using a clone of it here. One important note is that to program this type of device you do need what is called a FTDI board as it doesn't have built in usb support..

So we connect everything as shown in my drawing, I soldered everything right to the fio including the two transistors. (only one shown). I used shrink tubing to protect the leads from shorting out.

The Fio has a spot you can wire a simple switch to turn it off and on, which in this situation is important.

At this point we have it all wired and can test it.

On to the software

Step 3: What Is Embrio?

Embrio is a new way to program your Arduino boards using a visual approach. One of the things I've never liked about Arduino IDE is after learning to program with events is to go back to the old way of programming in a linear method. Embrio took a little while for me to figure out but it has the advantage of running multiple tasks at once and I don't have to think inside the LOOP function..

In Embrio I start with a Controller Input set it to digital pin 3 this lets us react to pin 3, Then I added a Above or Below agent and connect the Input activation to the Above or Below, so when pin is "active" it will fire off the Above or Below, then we connect the Go above trigger to a timer and connect the started and stopped triggers to a switch agent than then connects to my Arduino code that uses TONE command to start the piezo on a rising tone and also to a Controller Output set to digital pin 7 this tiggers the motor to come on, When the timer is finished it fires off the switch thus ending the noises.

You can install Embrio and test this code but will not be able to save it to the arduino without buying a license for Embrio.

You could do this all in Arduino IDE and that would look something like this: (This code works but not as well)

int inputPin = 3;                // choose the input pin (for PIR sensor)
int motorPin=7;
int buzzPin=6;
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
void setup() {
  pinMode(inputPin, INPUT);     // declare sensor as input
void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH</p><p>    
      // we have just turned on
      digitalWrite(motorPin,HIGH); //Spin motor
      tone(buzzPin,1000,50);       //Make tone on speaker
   else {  
      digitalWrite(motorPin,LOW);// Motor off
      noTone(buzzPin); 		//Tone off

Step 4: Design the Enclosure

Learned a few lessons here.

1) When designing parts to fit together don't forget to offset the size a little otherwise they won't go together.Main
2) Make sure that everything will fit. My first case everything in the lid hit something in the main part of the case.

Ok first things first, I've started doing most of my CAD designing in DesignSpark Mechanical. I found this Free CAD program the most intuitive for a non-engineer like myself. It has some short comings that I'll go over but basic building isn't one of them. For a introduction to DS Mechanical watch this video Intro to DS Mechanical or for more videos they have their own channel on YourTube

I designed this enclosure around a motor I had on hand, Mitsumi motor M25E-4L Series.

I made a hole in the lid then designed a bracket to hold the motor in place, this is held on with two m4 screws.

My gear is pushed onto the shaft of the motor. The Flapper arm is held on by a m3 screw and nut.

I won't go into designing in CAD but I did need to figure out how to make a gear to the size I needed.

Turns out that Inkscape the free SVG tool has a tool for that. Here is an Instrctable on Make your own gears. This is one of the areas that DS Mechanical let me down as I couldn't load the SVG so I used Tinkercad a free online tool, from that I exported as STL file and this I imported into DS Mechanical which does let you load STL files and even convert them back into solids to manipulate them like putting a hole in it for the motor shaft. DS also didn't do text so This too I did in TinkerCad as well and imported.

Also not in the main files is the little snoot I added to limit the area the PIR would see. This is optional.