Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1.  
  2. int wapda=0;
  3. int gen=0;
  4. int WAPDA=4;
  5. int GEN=5;
  6. int swit=2;
  7. int self=3;
  8. int count=0;
  9.  
  10.  
  11.  
  12. void setup() {
  13. // put your setup code here, to run once:
  14. pinMode(2,OUTPUT);//swit
  15. pinMode(3,OUTPUT);//self
  16. pinMode(4,INPUT);//wapda input
  17. pinMode(5,INPUT);//generator input
  18. Serial.begin(9600);
  19. }
  20.  
  21. void loop() {
  22. // put your main code here, to run repeatedly:
  23. wapda = digitalRead(WAPDA);
  24. gen = digitalRead(GEN);
  25.  
  26. if(wapda>0)
  27. swit=0;
  28.  
  29. if(wapda==0 && gen==0){
  30. digitalWrite(swit,HIGH);//switch turned on
  31. if(count<3){
  32. digitalWrite(self,HIGH);//do self
  33. delay(2000); //self for 5 seconds
  34. count++;
  35. digitalWrite(self,LOW);//turn off self
  36. delay(3000); //waiting for generator input
  37.  
  38. }
  39. if(digitalRead(GEN)==0){
  40. digitalWrite(swit,LOW); //turn off switch
  41. }
  42. if(digitalRead(GEN)==1 && count!=0){
  43. count=0;
  44. }
  45.  
  46. }
  47. Serial.println(wapda);
  48. Serial.println(gen);
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement