Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int wapda=0;
- int gen=0;
- int WAPDA=4;
- int GEN=5;
- int swit=2;
- int self=3;
- int count=0;
- void setup() {
- // put your setup code here, to run once:
- pinMode(2,OUTPUT);//swit
- pinMode(3,OUTPUT);//self
- pinMode(4,INPUT);//wapda input
- pinMode(5,INPUT);//generator input
- Serial.begin(9600);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- wapda = digitalRead(WAPDA);
- gen = digitalRead(GEN);
- if(wapda>0)
- swit=0;
- if(wapda==0 && gen==0){
- digitalWrite(swit,HIGH);//switch turned on
- if(count<3){
- digitalWrite(self,HIGH);//do self
- delay(2000); //self for 5 seconds
- count++;
- digitalWrite(self,LOW);//turn off self
- delay(3000); //waiting for generator input
- }
- if(digitalRead(GEN)==0){
- digitalWrite(swit,LOW); //turn off switch
- }
- if(digitalRead(GEN)==1 && count!=0){
- count=0;
- }
- }
- Serial.println(wapda);
- Serial.println(gen);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement