Hello i have this code:
and it works great, arduino detects the secret knock code and then releses the realy but i connect it to external powersuply (5v 1a, 5v 0,5a) through usb or vin strange things starting to happen. Arduino goes crazy and detects everything as knocking. Do you know why ?
Jabbadabbadahaht:
(5v 1a, 5v 0,5a)
What is it, 0,5A or 1A??? Little bit more details on the supply would help. And it only drives a relay? Sounds a supply that's or under powered of has a lot of ripple.
And yeah, connect it to the USB, Vin is only designed for voltages bigger then 7V.
Not looked at the code because it's at PastBin, not inline as it should be.
well i used 2 usb phone chargers that have 0,5Aor 1A. It worked on most of my other projects. First time I have prioblems with it.
Not answering all questions doesn't help you getting an answer any quicker 
oh yes the realy - yip there is only relay now. There was 2 leds but i removed them and switched one to pin 13. Also I powered it throught raspbery GPIO and it working there aswell.
Then I suspect to little decoupling in the power supply. But still not much details. Can you post a schematic (NO Fritzing, hand drawing will do) and a link to the relay?
Inline:
Yeah, that's a relay module. Try adding a +-470uF and a 100nF ceramic cap close to the Arduino across GND and Vcc.