You could control it with an app on your phone:
“Siri- open fire on the intruder”
“I detect 10 intruders 2 are fairly close to you. Which would you like me to eliminate?”
You can defend your house with a German Shepherd and with a gun. So mount the gun on the German Shepherd.
I’m with RickJay on this: no matter the robotic “IQ”, you’ve left a deathtrap to protect your property, the same moral issue as if you’d laid a minefield. Some innocent deliveryperson could come to (or toward) your door with a parcel, or a lost traveler asking for directions or emergency help, and die because your mechanism has no human discretion.
Move to Florida. Build your robot. Stand behind it when it opens fire.
Zombies don’t care about robots, as they don’t have brains.
Last time I looked into it, the BATFE considers any device which can fire more than one bullet over time with a single action to be a machine gun. Something like a gatling gun with a hand crank that keeps firing as you turn it is fine because it requires continuous action, and a double-barreled shotgun that can fire both barrels is fine because it happens at once, but anything where you press a button (like the on switch) and the device starts firing more than once is treated as a machine gun. Unless you’re licensed as a firearms manufacturer (this is a different license than a gun seller or collector has) and are manufacturing under specific conditions, it’s illegal to make a machine gun, so you’d be guilty of a federal crime without even considering the ‘deadly traps’ argument.
As in, a literal “machine” + “gun” == “machinegun”. I like it.