Thanks for reply,
Actually my project is working on logical condition.
You can understand by below code.
Where i mentioned push comment in actually LIMIT switch(Actually i have modified PUSHBUTTON code), and my limit switch is connected to 12v and 2amp battery. and i am
assuming limit switch is push button, when my push button get on, my solenoid (led in push button code) works.
after fulfill mentioned condition(in code) my solenoid will operate.
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... but what abt
current ??? 7805 is giving 500mA output can i use this current as arduino digital pin input???
/*
Button
Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 2.
The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
* Note: on most Arduinos there is already an LED on the board
attached to pin 13.
created 2005
by DojoDave <http://www.0j0.org>
modified 30 Aug 2011
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Button
*/
// constants won't change. They're used here to
// set pin numbers:
const int P1 = 2; // the number of the pushbutton pin
const int P2 = 3; // the number of the pushbutton pin
const int L1 = 4; // the number of the pushbutton pin
const 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
// variables will change:
int P1State = 0; // variable for reading the pushbutton status
int P2State = 0; // variable for reading the pushbutton status
int L1State = 0; // variable for reading the pushbutton status
int L2State = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(S4, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(P1, INPUT);
pinMode(P2, INPUT);
pinMode(L1, INPUT);
pinMode(L2, INPUT);
}
int blCheck=0;
void loop(){
// FOR FRONT AND REAR
P1State = digitalRead(P1);
P2State = digitalRead(P2);
L1State = digitalRead(L1);
L2State = digitalRead(L2);
if(P2State == HIGH)
{
blCheck=0;
}
if(P1State == HIGH)
{
blCheck=1;
}
if(blCheck == 1)
{
if (P1State == HIGH && L2State == LOW && P2State == LOW)
{
digitalWrite(S1, HIGH);
digitalWrite(S3, HIGH);
digitalWrite(S2, LOW);
digitalWrite(S4, LOW);
}
if (L2State == HIGH && P1State ==LOW && P2State == LOW)
{
digitalWrite(S1, LOW);
digitalWrite(S3, LOW);
digitalWrite(S2, HIGH);
digitalWrite(S4, HIGH);
}
if (L1State ==HIGH)
{
digitalWrite(S1, LOW);
digitalWrite(S3, LOW);
digitalWrite(S2, LOW);
digitalWrite(S4, LOW);
}
if (L2State ==HIGH && P1State==HIGH && P2State==LOW)
{
digitalWrite(S1, LOW);
digitalWrite(S3, LOW);
digitalWrite(S2, LOW);
digitalWrite(S4, LOW);
}
}
else
{
//FOR REAR DROP
if (P2State == HIGH && L2State == LOW && P1State==LOW)
{
// turn LED on:
digitalWrite(S3, HIGH);
digitalWrite(S4, LOW);
digitalWrite(S1, LOW);
digitalWrite(S2, LOW);
}
if (L2State == HIGH && P2State ==LOW && L1State == LOW)
{
digitalWrite(S1, LOW);
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
digitalWrite(S4, HIGH);
}
if (L2State ==HIGH && P2State==HIGH && P1State==LOW)
{
digitalWrite(S3, LOW);
digitalWrite(S4, LOW);
digitalWrite(S1, LOW);
digitalWrite(S2, LOW);
}
if (L1State ==HIGH)
{
digitalWrite(S1, LOW);
digitalWrite(S3, LOW);
digitalWrite(S2, LOW);
digitalWrite(S4, LOW);
}
}
}