I'm making a speedometer using arduino. I've made use of the interrupt pins to achieve the same. My problem is with the power source. I'm using a 12 V battery supply to power the arduino and I'm also using the same battery to use a horn. But, whenever I push the button to sound the horn, the IR sensor connected to the arduino is getting activated and I'm getting an erroneous reading. The only common thing between the arduino and the horn is the battery supply.
If the horn has a speaker coil or other magnetic actuator in it, then it will present an inductive load that may cause a voltage spike when you turn it off. Or, if it's a buzzer, it may generate voltage spikes all during its operation. Voltage spikes or other electrical noise are the most likely cause of the problem.
It also is possible that the horn draws enough current to drop your battery voltage so low that the Arduino or the sensors don't function reliably.
To find out which is the problem, take voltage readings with and without the horn in operation. If you have an oscilloscope, look for spikes on system power.
Try isolating and/or buffering the Arduino's power. If power glitches are the problem, that should fix the problem. If the problem is electromagnetically radiated electrical noise, further isolation (eg shielding) may be needed.
To isolate the Arduino's power, either operate it from another battery (which is something you can do anyway, while diagnosing the problem) or add one diode into the Arduino's power lead and another into the horn's. Connect an electrolytic capacitor, eg 100 to 1000 μF, from the Arduino's +V input to ground. If necessary add ferrite beads around the power leads.
A capacitor across 12 V from the battery will buffer the power, but for more isolation and buffering you can add a buck converter which can manufacture eg +7V from a +12V input while remaining relatively impervious to spikes on the +12V. Put the large electrolytic across the +7V if you use a buck converter.