We have a small dog who, from a young age, decided that the mat in our bathroom was the ideal place to have a sly wee. The problem was that we could never catch her doing it. We were resigned to having to put up with the smell of stale wee in the bathroom, and having to wash the bathmat every couple of days.
Then we got another dog. He decided that the mat under my desk was his personal toilet. Enough was enough! I had to find a way to deter these dogs from weeing on the mat.
Step 1: The parts
I went to my local electronics store and bought an infrared "light beam" intrusion alarm kit for about $40. This kit had to be assembled from components, but you could also use a regular IR intrusion detector from a home security system, or an infrared shop door alert buzzer - it's just more expensive.
You will need the type of detector that sets off an alarm when a light beam is interrupted. A passive Infrared sensor might work, but it's probably not as reliable and it will drive you crazy when you are using the bathroom.
Dogs typically don't like loud noises, particularly sudden ones. I coupled the intrusion detector with a 130dB piezoelectric siren. A 12V power supply ensured that the alarm would always be ready to deter the dogs.
Step 2: Setting it up
By placing the alarm with the infrared beam across the bathroom door, every time our dog poked her nose into the bathroom to wee on the bathmat, the alarm went off and she got a loud reminder that the bathroom is off limits.
After about 3 weeks, you can remove the alarm. By this time your dog will have learned that there are better places to wee - like outside.