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.