-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTruck_Simulator_Controller.ino
126 lines (107 loc) · 2.6 KB
/
Truck_Simulator_Controller.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "Button.h";
#include "Switch.h";
#include "IgnitionKey.h";
#include "LightRotarySwitch.h";
#include "RainWipersRotarySwitch.h";
const int PIN_BTN_1 = 2;
const int PIN_BTN_2 = 3;
const int PIN_BTN_3 = 4;
const int PIN_BTN_4 = 5;
const int PIN_BTN_5 = 6;
const int PIN_BTN_6 = 7;
const int PIN_SW_1 = 8;
const int PIN_SW_2 = 9;
const int PIN_SW_3 = 10;
const int PIN_KEY_1 = 10;
const int PIN_KEY_2 = 11;
const int PIN_KEY_3 = 12;
const int PIN_LIGHT_1 = 14;
const int PIN_LIGHT_2 = 15;
const int PIN_LIGHT_3 = 16;
const int PIN_LIGHT_4 = 17;
const int PIN_WIPERS_1 = 18;
const int PIN_WIPERS_2 = 19;
const int PIN_WIPERS_3 = 20;
//Object initialization
Button b1,b2,b3,b4,b5,b6;
Switch sw1,sw2,sw3;
IgnitionKey key1;
LightRotarySwitch light1;
RainWipersRotarySwitch wipers1;
void setup() {
pinMode(PIN_BTN_1, INPUT);
pinMode(PIN_BTN_2, INPUT);
pinMode(PIN_BTN_3, INPUT);
pinMode(PIN_BTN_4, INPUT);
pinMode(PIN_BTN_5, INPUT);
pinMode(PIN_BTN_6, INPUT);
pinMode(PIN_SW_1, INPUT);
pinMode(PIN_SW_2, INPUT);
pinMode(PIN_SW_3, INPUT);
pinMode(PIN_KEY_1, INPUT);
pinMode(PIN_KEY_2, INPUT);
pinMode(PIN_KEY_3, INPUT);
pinMode(PIN_LIGHT_1, INPUT);
pinMode(PIN_LIGHT_2, INPUT);
pinMode(PIN_LIGHT_3, INPUT);
pinMode(PIN_LIGHT_4, INPUT);
pinMode(PIN_WIPERS_1, INPUT);
pinMode(PIN_WIPERS_2, INPUT);
pinMode(PIN_WIPERS_3, INPUT);
Serial.begin(9600);
b1.setup(PIN_BTN_1, 1);
b2.setup(PIN_BTN_2, 2);
b3.setup(PIN_BTN_3, 3);
b4.setup(PIN_BTN_4, 4);
b5.setup(PIN_BTN_5, 5);
b6.setup(PIN_BTN_6, 6);
sw1.setup(PIN_SW_1, 7);
sw2.setup(PIN_SW_2, 8);
sw3.setup(PIN_SW_3, 9);
key1.setup(PIN_KEY_1, PIN_KEY_2, PIN_KEY_3, 10);
light1.setup(PIN_LIGHT_1, PIN_LIGHT_2, PIN_LIGHT_3, PIN_LIGHT_4, 11, 12);
wipers1.setup(PIN_WIPERS_1, PIN_WIPERS_2, PIN_WIPERS_3, 13);
}
void loop() {
/* 6 buttons */
b1.loop();
b2.loop();
b3.loop();
b4.loop();
b5.loop();
b6.loop();
/* Switch 2x
* On->Off = 1 button click
* Off->On = 1 button click
*/
sw1.loop();
sw2.loop();
/* Push-pull switch - breaks
* Push = 1 button click
* Pull = 1 butotn click
* This is basically the same as a switch so....
*/
sw3.loop();
/* Ignition key
* 0->1 battery - 1 button click
* 1->2->1 ignition - 1 button click
* 1->0 turn off - 1 button click
*/
key1.loop();
/* Light - two buttons
* 0->1 position lights (L)
* 1->2 short (L)
* 2->3 long (K)
* 3->2 short (K)
* 2->1 position lights (LL)
* 1->0 off (Ll)
*/
light1.loop();
/* Rain wipers - one button
* 0->1: 1 button click
* 1->2: 1 button click
* 2->1: 2 butoon clicks
* 1->0: 2 button clicks
*/
wipers1.loop();
}