You cannot sense the 12V directly and then have the arduino operate the solenoid, if that is what you are asking.The 12V must go thru a voltage divider first to keep the voltage level at 5V or below:12V (Vin)||>< R1>|| Vout to Arduino pin|>< R2>||Gnd

// constants won't change. They're used here to // set pin numbers:const int P1 = 2; // the number of the pushbutton pinconst int P2 = 3; // the number of the pushbutton pinconst int L1 = 4; // the number of the pushbutton pinconst int L2 = 5; // the number of the pushbutton pin

int S1 = 8; // the number of the LED pin int S2 = 9; // the number of the LED pin int S3 = 10; // the number of the LED pin int S4 = 11; // the number of the LED pin

There is a lot of not understanding the fundamentals of electricity going on here.

Quote

To controll VOLTAGE and amp, i am giving signal input to 7805 and 7805 output to arduino digital pin,by this way i am controlling voltage only

No that is very wrong. Yes it will control the maximum voltage but it will not give a good logic zero when there is no voltage. These chips are not designed for signal voltage level conversion, do not use them to do so.

Quote

7805 is giving 500mA output

No it is not.It is capable of giving 500mA only when it is put across a load that will demand 500mA. An arduino digital pin is high impedance so it will not draw anything like that much.

CrossRoads showed you how to read the 12V input correctly without misusing a voltage regulator.

Almost zero current flows into (or out of) an Arduino input. For most engineering purposes, you can assume zero current. (But, only if you stay within the limits of no more than 5V and no negative voltages.*)

The relationship between voltage resistance (or impedance) and current is described by Ohm's Law. Current = Voltage/Resistance. Resistance means "resistance to current flow". Ohm's Law is the 1st thing you learn when you take an electronics class.

Since the input impedance on the Arduino is 100 megohms or more, 5/100,000,000 = 0.02 microamps.

A power supply (or a voltage regulator like the LM340) does not "push out" 500mA. It puts-out a (approximately) constant voltage, and the current depends on the resistance of the load. If you exeed the limits of the power supply (by trying to get too much current out of it), Ohm's Law is still true (the laws of physics & nature always hold) so the voltage will drop (and the thing might burn-up).

* If you put a negative voltage, or a voltage greater than the 5V power supply, the internal protection diodes begin to conduct. At that point resistance drops to nearly zero, maximum current flows (whatever the source can supply) and your Arduino might get fried!