Using 2 arduinos, motorshield, relay and motor.

Hello everyone, hoping for some suggestions on how to approach adding a second arduino with a motorshield to control the motor and 2 bump sensors. I am adding the second arduino above to an already working arduino controlling a ping sensor and a 7 segment display which sends a signal from pin 13 to a relay which turns on a pump for a water gun. The idea is to put this water gun on a motor flush with a tank i built, so that the motor will swing back and forth between 2 bump sensors to give a sweeping motion, with the 1st arduino providing the stop signal to the motor so the pump will fire at the moment of breaching the sensors threshold. problem for me is that im new to using arduinos, so im not sure how to hook the motor, bump sensors and the 1st arduino together. Any help or suggestions would be greatly appreciated. Thanks!!

Why do you need two Arduinos? It doesn’t sound like you are taxing one yet.

Due to the motorshield and the bump sensors, i chose to utilize a second arduino, along with the first arduino housing (and driving) the 7 segment display shield, a ping sensor, and a relay to the water pump.

It's not the eases or best option. If you are running out of I/O pins look at using port expander or shift registers.

My concern is that the first arduino is sending the pulse from pin 13 to the relay that fires the water gun. The gun will need the motorshield close to help stop it when the firing sequence is sent to it, through the first arduino and relay. What I am asking for is help configuring the bump sensors and motorshield with the second arduino, then having the two arduinos "talk" to each other. Please help.

I don't know a lot about arduino...I thought that if you had one shield on it, you couldn't stack another one on top of it?? I was actually told to get 2 boards by one of the makershed guys. He was helping at one point but now is hard to get ahold of. I'm just looking for help... Now I'm confused even further...

Ok, I have 2 arduino duemilanove, 1 Ping sensor (made by parallax), 1 motorshield, 2 sets of screwshields, a 7 segment shield, a 3-6 VDC waterpump, a 5 VDC SPST NO 16 Amp Relay, a 12 v motor, and 2 sms-235 SPDT Snap action switches. This is what i have done so far, I have gotten the ping sensor to work by putting it to pin 7 for the signal, ground and 5v on the 1st arduino, through the 7 segment shield. The 7 segment shield shows the distance an object is in front of the ping sensor. Currently the ping sensor is set to calibrate the desired threshold when turned on. when the threshold is breached, the LED on the 7 seg shield goes red, and pin 13 lights and sends a signal to my relay. I have the relay set to so that it closes the circuit and triggers the waterpump to shoot. This is where i am lost. I had so much help from the makershed guy, but as I stated before, he kinda left me hanging. I know you are all thinking im silly or whatever, but I followed what he told me to do blindly, believing he would help me finish this project. I am not purposely trying to be difficult, or leave things out, I am simply lost and trying to find help wherever someone would be willing to help. Thank you for your time. :-[

I forgot to put in what I am trying to accomplish, sorry about that. The project was to complete with a gun, made from the squirting end of the pump, attached to a motor, that would swivel back and forth, until the arduino sends a signal to the pump to stop, and fire. I have the fire part, as i stated before...but how do i get the motor to stop, and how do i get the bump sensors working with the arduino? if there is a way to do this with only one, then im all ears, but i still need the 7 segment display to be visible. Im very open to suggestions.

This is where i am lost.

You lost me there. What is the problem exactly? That you can't close the relay? n that case, write a small program that does just that? If you're not sure what pins to use, make a schematic of your circuit. What pins are used by what shield, which are free?

With these kind of vague questions I can understand that other helpful people despair.


I have the relay closing, my issue is that I do not know how to hook the bump sensors and the motor into the motorshield/arduino combo, nor do I know how to program that to work. I have everything working up to this point. Just seriously confusing with the motor, and bump sensors into the arduino and motorshield, and how to get the two boards to talk so that the motor will stop with the signal from the 1st arduino board with the 7 seg shield that is already running.

how do i get the motor to stop

How did you get it to start?

bump sensors

Are these just micro switches of some kind? If so just tie one end of the switch to GND and the other to a spare input pin, enable the pullup resistors and read the value.

When the value goes low (after debouncing) turn the pump off.


Graynomad - I dont have the 12v motor running on the project as of yet. But I just had a thought, what if I used another relay to recieve the same pulse from pin 13 on the arduino to open the circuit thereby stopping the motor? As long as I put a diode in there to protect the board, should be good right? Its the same setup I have for the waterpump, but that motor is a 3-6v motor.

As for the bump switches, they are 2 sms-235 SPDT Snap action switches. Are you saying that if I follow what you said, they would reverse the motors direction when activated? if so, how? I thought that was why I was told to get another board....If i dont need it I would be happy to move forward without it.

Thank you all for your patience with me...Im pretty frustrated and frazzled.

I'll have to put this in point form to see if I've got the idea right. You want...

  • The "gun" to traverse left then right constantly.- When someone gets to close you want the gun to stop traversing and fire. Is that right? If not can you spell it out in a few bullet points like that.




The point of ANOTHER relay is that the first one is a normally open relay, and when activated it would close the circuit, thus making the gun fire. I want the opposite effect for the gun swinging motion, so I was thinking i would need a normally closed relay, that when it recieved the same pulse from pin 13, it would open, therefore STOPPING the motor, yet still firing the gun.

But wouldn't controlling the motor and firing the gun use two different controls (relays?). Now when you are controlling TWO DIFFERENT things (like the motor and the gun firing), that is where you DO need TWO relays (or whatever).

Yay! We agree! :) At least on the last part. I think you were misunderstanding me at first...the first (normally open) relay would solely be operating the water gun...but then somehow you understood my ramblings. lol.

I don't think you can do this with relays connected to a single output, if so you could just use a single 2-pole relay.

So have two "controls", relay, motorshield, whatever. One for the motor and another for the firing. Then two limit switches connected to Arduino inputs.

start motor running
do forever
   if either switch activated 
       swap direction

   if person too close 
       stop motor
       fire gun
       start motor

I think that's about all there is to it. The "start motor" is redundant most of the time but doesn't do any harm and simplifies the code.

Of course if you plan to shoot the person you have no way of know where ther are, just that they are close.