Arduino & Solenoid from 12V battery.

Hi,

I am going to use an Arduino to turn a solenoid on and off. To protect the Arduino from the surge released when the solenoid is powered down I am using the Arduino power a relay that will complete the circuit between the solenoid and the battery. Both the Arduino and the solenoid will be powered from the same battery.

I am concerned that the use of the relay will be pointless, in that as the arduino and solenoid are hooked up to the same battery the current could still fry the Arduino.

I will be using a large 12V marine battery which has two anodes and two cathodes, will using one of each for each circuit (arduino & solenoid) help? The solenoid is 12V and 5A.

I have heard of a method that uses a diode and transistor to protect the arduino on the same circuit. Would this be a better solution?

either coil will store energy and resist change. when the magnetic field collapses a voltage spike is created.
the way to prevent that from damaging you sensitive equipment is to dump that voltage. the most wildly used method is to put a diode across the coil leads. obviously set to prevent the V+ side from shorting into Ground.

since you will need to drive the coil with a transistor of some sort, the transistor could become the sacrificial lamb. alas, the diode usually works so well, nothing gets fried.

A freewheel diode rated at at least 5A pulse, and a logic-level MOSFET with 0.02 ohms or less R(on) will
work for that solenoid.

The freewheel diode allows a non-destructive path for current to flow when the switch opens.

I apologize for not posting correctly. I am trying to figure out how to control a stand alone mechanical relay with an arduino to turn on and off a lamp using the serial monitor in IDE. The relay is 6vDC. I have a 6vDC battery. I was going to plug an extension cord into an outlet and splice one of the wires. I would then wire one wire to the common terminal on the relay and the other to the normally open terminal. I would then connect the relay to the 6vDC battery positive and negative leads. I don't know how I would connect the arduino to the circuit so that I could control it through serial monitor. Any help would be greatly appreciated. Please also let me know how to post this correctly in the correct forum.
Thanks!
Shawn.