relay switching on and off very fast?!?!?

Can someone please advise me what I am doing wrong here? this should be very simple and when I look at it in the serial monitor everything looks like it is correct but my relay conected to pin 13 just switchs on and off very quickly no mater what I do. I have switched relays and boards same result. I have no clue what is wrong. I added a 5 second delay and still doing the same thing?!?!?

int sen = 3; int val = 13; int pond;

void setup(){ pinMode(val, OUTPUT); pinMode(sen, INPUT); Serial.begin(9600); }

void loop(){ pond = digitalRead(sen); if (pond == HIGH) { digitalWrite(val, HIGH); } else{ digitalWrite(val, LOW); } delay(5000); //Serial.println((String)status+"Valve"); //Serial.println((String)pond+"sen D3"); }

What is connected to pin 3?

Please post a link to the relay, and a wiring diagram.

If you are trying to power the relay from the Arduino 5V, that may be the problem.

I am using a nano not an UNO but this is the basic wire diagram i am using. I have tried with both a solid state and standard relay same results. I am powering the relay off the board, I have done so in the past on other projects without issue, but I will try powering separately and see if that resolves the issue.

https://www.dropbox.com/s/jimxxzbxeyrenj8/button_schem.png?dl=0

Please attach images, and post them in line, as described here.

If the delay() does nothing, then the Arduino is being reset very rapidly. That is almost always due to a power problem.

jremington:
Please attach images, and post them in line, as described here.

If the delay() does nothing, then the Arduino is being reset very rapidly. That is almost always due to a power problem.

That did it jremington it was the power supply guess it finally failed. Thank you!