Urgent help-Water pump problems

Hi guys,
I need help urgently...
I am trying to make an automatic water dispenser using pump with Arduino..
I have a 12v pump and an Arduino relay, an Arduino nano and an ultrasonic sensor..
My problem is this
When I test my circuit without the water pump connected, everything works fine with the relay triggering as at when it should..
But when I connect the pump to the circuit, it starts misbehaving...
The ultrasonic sensor is supposed to trigger the relay when it senses something for the pump to work...
But when it senses something, the pump works but keeps working even though I have removed it which isn't supposed to be..
Now, the pump is being powered by a 12v 2A adaptor..
I also tapped the power for the Arduino from the same adaptor..
Any advice on what to do to make it work because I have just 2days left to submit the project...
Thanks allot...

Without knowing which exact parts that you have, a schematic and your code it is harder to help. From what you say, a lack of power is the most likely problem. What is the stall current of the pump motor?

If it all works perfectly when the pump is not connected, then electrical noise introduced by the pump is clearly to be suspected.
Some things to try (it's a 12VDC pump) are to reverse a diode across the pump. Also try a separate power source for the Nano instead of sharing it with the pump (say USB cable from your PC). Anyway, post a circuit diagram showing how it is all connected up.

Cross-post.

6v6gt:
If it all works perfectly when the pump is not connected, then electrical noise introduced by the pump is clearly to be suspected.
Some things to try (it's a 12VDC pump) are to reverse a diode across the pump. Also try a separate power source for the Nano instead of sharing it with the pump (say USB cable from your PC). Anyway, post a circuit diagram showing how it is all connected up.

I tried using a different power source and it worked normally but I do have to use just one power source, any idea?

Still a cross-post.

TheMemberFormerlyKnownAsAWOL:
Still a cross-post.

Is there a way I can delete the other post?
Am sorry for that..

Raydar:
Is there a way I can delete the other post?
Am sorry for that..

You could ask a helpful moderator.
I've already done that for you.

TheMemberFormerlyKnownAsAWOL:
You could ask a helpful moderator.
I've already done that for you.

Thanks

Raydar:
Is there a way I can delete the other post?
Am sorry for that..

what you could have done...
is edited your other post. bottom right, more, mofify, then put a note in front of your question 'duplicate, sorry'
and edit your subject line.
alas, you already have people who responded on that one so sit back, relax, one of the moderators will be by and merge the two and select which forum to have the final version placed.
beginners mistake and no harm done.

We need more details on the relay.
is it just a blue relay or is it a relay module with the relay attached to a circuit board ?
can you post link to relay or photo of same ?

huge mistake is that you are powering the relay from the Arduino. the relay should get power from a different power source, and share a ground to the Arduino.
#2) no resistor between the Arudino output pin and the relay signal pin

I am impressed that you can run an Arduino, sensor and relay without a power supply.

Raydar:
I tried using a different power source and it worked normally but I do have to use just one power source, any idea?

I guess that the schematic illustrates the circuit when the Arduino is powered via the USB and the pump via the 12 volt adapter. How did you wire it when you used a single power source for both ?

6v6gt:
I guess that the schematic illustrates the circuit when the Arduino is powered via the USB and the pump via the 12 volt adapter. How did you wire it when you used a single power source for both ?

The power of the Arduino was tapped also from the adaptor, I forgot to illustrate that ..

6v6gt:
I guess that the schematic illustrates the circuit when the Arduino is powered via the USB and the pump via the 12 volt adapter. How did you wire it when you used a single power source for both ?

Thanks guys, it works perfectly now by just reversing a diode across the pump..
Am so happy..

Make sure your Arduino's on-board regulator gets some proper cooling.

Operating an Arduino off 12V is pretty much the limit it can do. Adding a relay and you will start overheating your regulator, which may cause it to simply shut down.

The proper way to power this project is a separate 5V supply for your Arduino - or if it must be off that 12V supply, use a buck converter to step down 12V to 5V. The 5V of course goes to the 5V pin, not the Vin pin which is for >7V.