Relais


SUBMITTED BY: bitcoinsachen

DATE: March 6, 2017, 7:43 p.m.

UPDATED: March 6, 2017, 7:59 p.m.

FORMAT: C

SIZE: 2.3 kB

HITS: 1048

  1. void setup() {
  2. // put your setup code here, to run once:
  3. pinMode(2,INPUT);
  4. pinMode(3,INPUT);
  5. pinMode(4,INPUT);
  6. pinMode(5,INPUT);
  7. pinMode(6,INPUT);
  8. pinMode(7,INPUT);
  9. pinMode(8,INPUT);
  10. pinMode(9,INPUT);
  11. pinMode(A0,OUTPUT);
  12. pinMode(A1,OUTPUT);
  13. pinMode(A2,OUTPUT);
  14. pinMode(A3,OUTPUT);
  15. pinMode(A4,OUTPUT);
  16. pinMode(A5,OUTPUT);
  17. pinMode(A6,OUTPUT);
  18. pinMode(A7,OUTPUT);
  19. int relais1=0;
  20. int relais2=0;
  21. int relais3=0;
  22. int relais4=0;
  23. int relais5=0;
  24. int relais6=0;
  25. int relais7=0;
  26. int relais8=0;
  27. while(5){
  28. int pin1 = digitalRead(2);
  29. int pin2 = digitalRead(3);
  30. int pin3 = digitalRead(4);
  31. int pin4 = digitalRead(5);
  32. int pin5 = digitalRead(6);
  33. int pin6 = digitalRead(7);
  34. int pin7 = digitalRead(8);
  35. int pin8 = digitalRead(9);
  36. //Relais1
  37. if(pin1==1){
  38. relais1++;
  39. //digitalWrite(A0, HIGH);
  40. delay(50);
  41. }
  42. if(relais1 == 0){
  43. digitalWrite(A0,HIGH);
  44. }
  45. if (relais1==1){
  46. digitalWrite(A0,LOW);
  47. }
  48. if(relais1==2){
  49. relais1=0;
  50. }
  51. //Relais2
  52. if(pin2==1){
  53. relais2++;
  54. delay(50);
  55. }
  56. if(relais2 == 0){
  57. digitalWrite(A1,HIGH);
  58. }
  59. if (relais2==1){
  60. digitalWrite(A1,LOW);
  61. }
  62. if(relais2==2){
  63. relais2=0;
  64. }
  65. //Relais3
  66. if(pin3==1){
  67. relais3++;
  68. delay(50);
  69. }
  70. if(relais3 == 0){
  71. digitalWrite(A2,HIGH);
  72. }
  73. if (relais3==1){
  74. digitalWrite(A2,LOW);
  75. }
  76. if(relais3==2){
  77. relais3=0;
  78. }
  79. //Relais4
  80. if(pin4==1){
  81. relais4++;
  82. delay(50);
  83. }
  84. if(relais4 == 0){
  85. digitalWrite(A3,HIGH);
  86. }
  87. if (relais4==1){
  88. digitalWrite(A3,LOW);
  89. }
  90. if(relais4==2){
  91. relais4=0;
  92. }
  93. //Relais5
  94. if(pin5==1){
  95. relais5++;
  96. delay(50);
  97. }
  98. if(relais5 == 0){
  99. digitalWrite(A4,HIGH);
  100. }
  101. if (relais5==1){
  102. digitalWrite(A4,LOW);
  103. }
  104. if(relais5==2){
  105. relais5=0;
  106. }
  107. //Relais6
  108. if(pin6==1){
  109. relais6++;
  110. delay(50);
  111. }
  112. if(relais6 == 0){
  113. digitalWrite(A5,HIGH);
  114. }
  115. if (relais6==1){
  116. digitalWrite(A5,LOW);
  117. }
  118. if(relais6==2){
  119. relais6=0;
  120. }
  121. //Relais7
  122. if(pin7==1){
  123. relais7++;
  124. delay(50);
  125. }
  126. if(relais7 == 0){
  127. digitalWrite(A6,HIGH);
  128. }
  129. if (relais7==1){
  130. digitalWrite(A6,LOW);
  131. }
  132. if(relais7==2){
  133. relais7=0;
  134. }
  135. //Relais8
  136. if(pin8==1){
  137. relais8++;
  138. delay(50);
  139. }
  140. if(relais8 == 0){
  141. digitalWrite(A7,HIGH);
  142. }
  143. if (relais8==1){
  144. digitalWrite(A7,LOW);
  145. }
  146. if(relais8==2){
  147. relais8=0;
  148. }
  149. }
  150. }

comments powered by Disqus