1 | const int blinkenrechts = 4 ;//oben K4
|
2 | const int blinkenlinks = 5 ;//oben K3
|
3 | const int standlicht = 3 ;//obenK2
|
4 | const int ruecklicht = 2 ;//oben K1
|
5 | const int fernlicht = 9 ;//unten K4
|
6 | const int bremslicht = 8 ;//unten K3
|
7 | const int regler = 7 ;//unten K2
|
8 | const int zuendung = 6 ;//unten K1
|
9 | const int batterie = 14 ;
|
10 | const int anlasser = 16;
|
11 | const int hupe = 17;
|
12 |
|
13 | int a1 = 0;
|
14 | int a2 = 0;
|
15 | int a = 0;
|
16 |
|
17 |
|
18 | #include <Wire.h>
|
19 |
|
20 | void setup() {
|
21 | // put your setup code here, to run once:
|
22 |
|
23 | pinMode( blinkenrechts , OUTPUT);
|
24 | pinMode( blinkenlinks , OUTPUT);
|
25 | pinMode( standlicht , OUTPUT);
|
26 | pinMode( ruecklicht , OUTPUT);
|
27 | pinMode( fernlicht , OUTPUT);
|
28 | pinMode( bremslicht , OUTPUT);
|
29 | pinMode( regler , OUTPUT);
|
30 | pinMode( zuendung , OUTPUT);
|
31 | pinMode( batterie , OUTPUT);
|
32 | pinMode( anlasser , OUTPUT);
|
33 | pinMode( hupe , OUTPUT);
|
34 | Wire.begin(8); // join i2c bus with address #8
|
35 | Wire.onReceive(receiveEvent); // register event
|
36 | Serial.begin(9600); // start serial for output
|
37 | }
|
38 |
|
39 | void loop() {
|
40 | // put your main code here, to run repeatedly:
|
41 | if (a1 = a)
|
42 | {}
|
43 | else
|
44 | { a1 = a;
|
45 | a2 = a;
|
46 | if (a2 >= 128)
|
47 | { a2 = a2 - 128;
|
48 | digitalWrite(zuendung , HIGH);
|
49 | digitalWrite(batterie , HIGH);
|
50 | digitalWrite(regler , HIGH);
|
51 | }
|
52 | else
|
53 | { digitalWrite(zuendung , LOW);
|
54 | digitalWrite(batterie , LOW);
|
55 | digitalWrite(regler , LOW);
|
56 | }
|
57 | if (a2 >= 64)
|
58 | { a2 = a2 - 64;
|
59 | bool rfstatus = HIGH;
|
60 | }
|
61 | else
|
62 | { bool rfstatus = LOW;
|
63 | }
|
64 | if (a2 >= 32)
|
65 | { a2 = a2 - 32;
|
66 | digitalWrite(bremslicht , HIGH);
|
67 | }
|
68 | else
|
69 | { digitalWrite(bremslicht , LOW);
|
70 | }
|
71 | if (a2 >= 16)
|
72 | { a2 = a2 - 16;
|
73 | digitalWrite(fernlicht , HIGH);
|
74 | }
|
75 | else
|
76 | { digitalWrite(fernlicht , LOW);
|
77 | }
|
78 | if (a2 >= 8)
|
79 | { a2 = a2 - 8;
|
80 | digitalWrite(blinkenlinks , HIGH);
|
81 | }
|
82 | else
|
83 | { digitalWrite(blinkenlinks , LOW);
|
84 | }
|
85 | if (a2 >= 4)
|
86 | { a2 = a2 - 4;
|
87 | digitalWrite(blinkenrechts , HIGH);
|
88 | }
|
89 | else
|
90 | { digitalWrite(blinkenrechts , LOW);
|
91 | }
|
92 | if (a2 >= 2)
|
93 | { a2 = a2 - 2;
|
94 | digitalWrite(hupe , HIGH);
|
95 | }
|
96 | else
|
97 | { digitalWrite(hupe , LOW);
|
98 | }
|
99 | if (a2 >= 1)
|
100 | { a2 = a2 - 1;
|
101 | bool leerlaufstatus = HIGH;
|
102 | }
|
103 | else
|
104 | { bool leerlaufstatus = LOW;
|
105 | }
|
106 | Serial.println(a );
|
107 | }
|
108 |
|
109 | void receiveEvent(int HowMany) {
|
110 |
|
111 | int a = Wire.read();
|
112 |
|
113 |
|
114 | }
|