1 | const int K1_A_0 = 2; //Wand 0=aus, 1=ein DO
|
2 | const int K2_B_0 = 3; //Scharnier 0=aus, 1=ein DO
|
3 | const int K3_C_0 = 4; //Monitor 0=aus, 1=ein DO
|
4 | const int K4_A_1 = 5; //Wand 0=rechts, 1=links DO
|
5 | const int K5_B_1 = 6; //Scharnier 0=rechts, 1=links DO
|
6 | const int K6_C_1 = 7; //Monitor 0=rechts, 1=links DO
|
7 | const int Achse_A_0 = 8; //Wand 1=eingefahren DI
|
8 | const int Achse_A_1 = 9; //Wand 1=ausgefahren DI
|
9 | const int Achse_B_0 = 10; //Scharnier 1=eingefahren DI
|
10 | const int Achse_B_1 = 11; //Scharnier 1=ausgefahren DI
|
11 | const int Achse_C_0 = 12; //Monitor 1=eingefahren DI
|
12 | const int Achse_C_1 = 13; //Monitor 1=ausgefahren DI
|
13 | const int S1 = A0; //Poti Wand 0-250=rechts, 251-750=Stopp, 751-1000=links, 1001-1024= Grundstellung AI
|
14 | const int S2 = A1; //Poti Scharnier 0-250=rechts, 251-750=Stopp, 751-1000=links AI
|
15 | const int S3 = A2; //Poti Monitor 0-250=rechts, 251-750=Stopp, 751-1000=links AI
|
16 |
|
17 | int _S1_Value = 0; //Potiwert Wand
|
18 | int _S2_Value = 0; //Potiwert Scharnier
|
19 | int _S3_Value = 0; //Potiwert Monitor
|
20 |
|
21 | int _Achse_A_0_Value = 0; //Wand eingefahren
|
22 | int _Achse_A_1_Value = 0; //Wand ausgefahren
|
23 | int _Achse_B_0_Value = 0; //Scharnier eingefahren
|
24 | int _Achse_B_1_Value = 0; //Scharnier ausgefahren
|
25 | int _Achse_C_0_Value = 0; //Monitor eingefahren
|
26 | int _Achse_C_1_Value = 0; //Monitor ausgefahren
|
27 |
|
28 | void setup()
|
29 | {
|
30 | Serial.begin(9600);
|
31 |
|
32 | pinMode (K1_A_0, OUTPUT);
|
33 | pinMode (K2_B_0, OUTPUT);
|
34 | pinMode (K3_C_0, OUTPUT);
|
35 | pinMode (K4_A_1, OUTPUT);
|
36 | pinMode (K5_B_1, OUTPUT);
|
37 | pinMode (K6_C_1, OUTPUT);
|
38 | pinMode (Achse_A_0, INPUT);
|
39 | pinMode (Achse_A_1, INPUT);
|
40 | pinMode (Achse_B_0, INPUT);
|
41 | pinMode (Achse_B_1, INPUT);
|
42 | pinMode (Achse_C_0, INPUT);
|
43 | pinMode (Achse_C_1, INPUT);
|
44 | }
|
45 |
|
46 | void loop()
|
47 | {
|
48 |
|
49 |
|
50 | {
|
51 |
|
52 | Serial.print("Achse_A_0 ");
|
53 | Serial.println(digitalRead(Achse_A_0));
|
54 | Serial.print("Achse_A_1 ");
|
55 | Serial.println(digitalRead(Achse_A_1));
|
56 | Serial.print("Achse_B_0 ");
|
57 | Serial.println(digitalRead(Achse_B_0));
|
58 | Serial.print("Achse_B_1 ");
|
59 | Serial.println(digitalRead(Achse_B_1));
|
60 | Serial.print("Achse_C_0 ");
|
61 | Serial.println(digitalRead(Achse_C_0));
|
62 | Serial.print("Achse_C_1 ");
|
63 | Serial.println(digitalRead(Achse_C_1));
|
64 | Serial.print("Poti 1 ");
|
65 | Serial.println(analogRead(_S1_Value));
|
66 | Serial.print("Poti 2 ");
|
67 | Serial.println(analogRead(_S2_Value));
|
68 | Serial.print("Poti 3 ");
|
69 | Serial.println(analogRead(_S3_Value));
|
70 | Serial.println(" ");
|
71 |
|
72 |
|
73 | }
|
74 |
|
75 |
|
76 | {
|
77 |
|
78 | _Achse_A_0_Value = digitalRead(Achse_A_0);
|
79 | _Achse_A_1_Value = digitalRead(Achse_A_1);
|
80 | _Achse_B_0_Value = digitalRead(Achse_B_0);
|
81 | _Achse_B_1_Value = digitalRead(Achse_B_1);
|
82 | _Achse_C_0_Value = digitalRead(Achse_C_0);
|
83 | _Achse_C_1_Value = digitalRead(Achse_C_1);
|
84 | _S1_Value = analogRead(S1);
|
85 | _S2_Value = analogRead(S2);
|
86 | _S3_Value = analogRead(S3);
|
87 | }
|
88 |
|
89 | // Achse Wand
|
90 |
|
91 |
|
92 |
|
93 | if ((_S1_Value == 0 < 250) && (_Achse_A_1_Value == 0)) //Achse Wand ausfahren (links)
|
94 | {
|
95 | digitalWrite(K1_A_0, HIGH);
|
96 | digitalWrite(K4_A_1, HIGH);
|
97 | }
|
98 |
|
99 |
|
100 | if (((_S1_Value == 750 < 1000) && (_Achse_A_0_Value == 0)) || ((_S1_Value > 1001) && (_Achse_A_0_Value == 0))) //Achse Wand einfahren (rechts)
|
101 | {
|
102 | digitalWrite(K1_A_0, HIGH);
|
103 | digitalWrite(K4_A_1, LOW);
|
104 | }
|
105 |
|
106 | if ((_S1_Value == 251 < 749) && (_S1_Value < 1001)) //Achse Wand Stopp
|
107 | {
|
108 | digitalWrite(K1_A_0, LOW);
|
109 | digitalWrite(K4_A_1, LOW);
|
110 | }
|
111 |
|
112 |
|
113 | //Achse Scharnier
|
114 |
|
115 |
|
116 |
|
117 | if ((_S2_Value == 0 < 250) && (_Achse_B_1_Value == 0)) //Achse Scharnier ausfahren (auf)
|
118 | {
|
119 | digitalWrite(K2_B_0, HIGH);
|
120 | digitalWrite(K5_B_1, HIGH);
|
121 | }
|
122 |
|
123 |
|
124 | if (((_S2_Value == 750 < 1025) && (_Achse_B_0_Value == 0)) || ((_S1_Value > 1001) && (_Achse_B_0_Value == 0))) //Achse Scharnier einfahren (zu)
|
125 | {
|
126 | digitalWrite(K2_B_0, HIGH);
|
127 | digitalWrite(K5_B_1, LOW);
|
128 | }
|
129 |
|
130 | if ((_S2_Value == 251 < 749) && (_S1_Value < 1001)) //Achse Scharnier Stopp
|
131 | {
|
132 | digitalWrite(K2_B_0, LOW);
|
133 | digitalWrite(K5_B_1, LOW);
|
134 | }
|
135 |
|
136 |
|
137 | //Achse Monitor
|
138 |
|
139 |
|
140 | if ((_S3_Value == 0 < 250) && (_Achse_C_1_Value == 0)) //Achse Monitor ausfahren
|
141 | {
|
142 | digitalWrite(K3_C_0, HIGH);
|
143 | digitalWrite(K6_C_1, HIGH);
|
144 | }
|
145 |
|
146 |
|
147 | if (((_S3_Value == 750 < 1025) && (_Achse_C_0_Value == 0)) || ((_S1_Value > 1001) && (_Achse_C_0_Value == 0))) //Achse Monitor einfahren
|
148 | {
|
149 | digitalWrite(K3_C_0, HIGH);
|
150 | digitalWrite(K6_C_1, LOW);
|
151 | }
|
152 |
|
153 | if ((_S3_Value == 251 < 749) && (_S1_Value < 1001)) //Achse Monitor Stopp
|
154 | {
|
155 | digitalWrite(K3_C_0, LOW);
|
156 | digitalWrite(K6_C_1, LOW);
|
157 | }
|
158 |
|
159 |
|
160 | delay (3500);
|
161 |
|
162 |
|
163 | }
|