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: 1045

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

comments powered by Disqus