Go Down

Topic: Keeping the dog off the couch (Read 2477 times) previous topic - next topic

Apr 22, 2012, 07:49 pm Last Edit: Apr 22, 2012, 07:51 pm by kevinlongisland Reason: 1
Hello all!  I'm super happy to have finished my very first arduino project.  

Objective:  Keep the dogs off the couch

Summary:  Using the sparkfun inventorys kit, I first tried to use the flex sensor.  Unfortunately the flex sensor was damaged out of the box.  While looking to purchase a replacement I found force sensors and ordered some of those as that is what I feel will be the final version of this project.  But not wanting to stop there and wait for parts, I then created a system to detect a break in a light source that triggers a beeper.

Analysis:  My first two thoughts to detect when the dogs get on the couch where either a flex sensor or the breaking of a light beam.  I don't like the idea of breaking a light beam as the components to do this are not easily hidden from view (it's ugly and visible system to guests).  Hence why I started with the flex sensor concept.  I first started by constructing the sparkfun inventors kit project for the flex sensor.  I built the setup, acquired the code, and uploaded.  Nothing.  After some troubleshooting, I determined the flex sensor was not working.  The good thing is while ordering a new flex sensor I found force sensors.  I believe these will work perfectly under one leg of the couch (easy to hide) to determine when a dog gets up on the couch so I've ordered some.

But because I was in the mood to experiment, I decided to continue with the breaking of a light beam part of the project.  By combining snippets of code from several of the experiments in the sparkfun inventors kit I was able to make an operable system to do this.  Here is my code, which is not perfect as the buzzer sound has some issues.  I'm guessing it's due to re-initiation of the note() function over and over again.  The Serial.begin(9600) was extremely useful to calibrate the system and set the threshold value to activate the tone().  Any constructive criticism of my code is appreciated as that's the best way to learn!  :)  Thanks.


Code: [Select]
//PhotoResistor Pin
int lightPin = 0; //the analog pin the photoresistor is
                 //connected to
                 //the photoresistor is not calibrated to any units so
                 //this is simply a raw sensor value (relative light)
//LED Pin
int ledPin = 9;   //the pin the LED is connected to
                 //we are controlling brightness so
                 //we use one of the PWM (pulse width
                 // modulation pins)
void setup()
{
 Serial.begin(9600);
 pinMode(ledPin, OUTPUT); //sets the led pin to output
}
/*
* loop() - this function will start after setup
* finishes and then repeat
*/
void loop()
{
int lightLevel = analogRead(lightPin); //Read the
                                       // lightlevel
 Serial.println(lightLevel);
 int threshold = 1000;
 if(analogRead(lightPin) > threshold){
   digitalWrite(ledPin, HIGH);
   tone(8,6000);
 }else{
   digitalWrite(ledPin, LOW);
  noTone(8);
delay(900);
}
}

zoomkat

Probably cheaper, simpler, and faster to use a deterrant like the below Fi-Shock pet and small animal unit to train the dogs to stay off of the couch. I've got one and it is not in-humane as I have "trained" myself a couple of times getting it set up. Tape some bare wires on the surface of the couch (or use aluminum foil pads/strips) and connect to the unit. The dog will get the appropriate immediate negative reinforcement when it jumps up on the couch and gets across the conductors. Pets are furry and somewhat insulated, so the contact usually needs to be with the feet/nose or other more exposed body parts. I think I got my unit at Lowes, but a number of places carry them.

http://www.fishock.com/store/electric-fence-charger/ss-725rp

http://www.google.com/search?hl=en&lr=&cr=&safe=images&um=1&ie=UTF-8&tbo=u&tbm=shop&source=og&q=fi-shock%20pet&sa=N&tab=wf&ei=uluUT8ySB4Kx6QGg-aycBA
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Whats an easy way to generate 20khz to 40khz sound waves with an arduino?  I want to use ultrasonic waves to annoy the dog when it hops on the couch.

The US sensor SFR05 produces 40 kHz (if I remember correctly). Perhaps you can use it.

best regards
Andreas
http://danimathblog.blogspot.com

#define true '/'/'/'
#define false '-'-'-'

AWOL

Quote
Whats an easy way to generate 20khz to 40khz sound waves with an arduino?

A 555 and a Murata ultrasonic transmitter.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

cjdelphi

kill 2 birds with one stone :D

http://www.ebay.com.au/itm/Arduino-Ultrasonic-Module-HC-SR04-Sensor-Ranging-Distance-Measuring-Transducer-/180843355708?pt=AU_B_I_Electrical_Test_Equipment&hash=item2a1b1a9e3c

//setup
 


//loop

boolean dogdetected = false;

if (distance<100)
      dogdetected=true;
  else
    dogdetected=false;


if (dogdetected==false)
  Delay(250);
else
    Delay(1);   


(just typed it out, so fix the syntax mistakes)

so it goes from a slow pulse of 1/4th a second to see if it finds the dog and when it does...
it goes spastic sending out a constant high pitched squeals making sure the dog gets the hell
off....

when it does, it returns to 250ms delays... (AU $3.35 free postage) i bought 2 of them, not that great
but works really well measuring things <100cm or so or the sound waves bounce everything and you get not
so nice oscillation patters like mind do, i need to try soft mats to soak up the sound waves...

SirNickity

Love the project.  Anyone working on a similar device to keep cats off of a kitchen counter?  Movement tracking with a servo-operated spray bottle would be great.   ]:D

I received my force sensors today to use under one leg of the couch. This allows for easy concealment of the electronics and sensors. I ordered a "dog repellent and training aid" device off amazon for $16. I'll just interface that easily with the arduino and it should already be tuned to the optimal frequency to bother the dog. I'll find something nice to put it in and drill a hole in the side to emit the ultrasound. Hopefully the entire setups aesthetics will be acceptable to my girlfriend and functional. 

I can probably calibrate the system as well to run all the time and not trigger above a certain threshold when my girlfriend or I sit on the couch. But only trigger within the range the dog creates. 

WizenedEE

I'm guessing a problem may occur in that when you sit on the couch, the force will go up slowly enough that it would turn on and annoy the dog. If you program a delay (it might be between x and y for 1 second), then you lose the immediate negative reinforcement. Also, he may learn to sit far from the leg with the sensor to avoid detection.

As a backup plan, I'd suggest a force sensor under the cushion, since it seems that it would avoid maxing out the sensor and also have a greater percent difference in weight.

Good luck

Wiz, I believe one force sensor can be appropriately calibrated to work if the dog sits on either end of the couch. And if not, two force sensors can be used and the sum of their forces can be used to determine the trigger point. That would eliminate any issues with what side of the couch the dog rests on. 

Also, I'm sure programming can easily deal with the issue of false triggers as the weight rises and falls when heavier animals (humans) sit on and get up from the couch. 

zoomkat

You might get one of the below and set it on the couch. There are other DIY gizmos that can be made to harmlessly startle dogs and cats when they go into undesired places.

http://www.ebay.com/itm/Security-Door-Window-Vibration-Detector-Burglar-Alarm-/110736354308?pt=LH_DefaultDomain_0&hash=item19c866ac04
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Zoomcat, don't you love those s2000's!!  I had one last year. A great car. 

As far as the vibration sensing alarm, i can't have anything that will also wake my girlfriend and I at night while we sleep. So no loud sirens or buzzers.  And the vibration part might be tough to calibrate to distinguish human vs dog. 

Go Up