When the tilt sensor is on, its basically shorting out your pin 2 which is at 5V directly to ground, which as i understand is a really bad idea bcos it can cause a massive current surge more than the accepted input mA current rating?. Maybe a pull-up resistor configuration where the tilt switch is between input pin and ground , and there is a 10k ohm resistor from 5V to input pin to would be better?