-
Notifications
You must be signed in to change notification settings - Fork 0
/
rangefinder.ino
70 lines (61 loc) · 1.39 KB
/
rangefinder.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
#include "Activator.h"
#include "Mast.h"
#include "Blinkenlights.h"
#include "Screen.h"
const byte ACTIVATOR_AIMING_PIN = 2;
const byte ACTIVATOR_FLASHLIGHT_PIN = 7;
const byte BLINKEN_TOP_PIN = 3;
const byte BLINKEN_BOTTOM_PIN = 4;
const byte BLINKEN_FLASHLIGHT_PIN = 6;
const byte SCREEN_PIN = 5;
const byte MAST_SERVO_PIN = 9;
const int MAST_RAISED_ANGLE = 100;
const int MAST_LOWERED_ANGLE = 0;
const unsigned long ACTIVATOR_TIMEOUT = 500;
const unsigned long MAST_TIMEOUT = 15000;
const unsigned long BLINKEN_INTERVAL = 250;
Activator activator(
ACTIVATOR_AIMING_PIN,
ACTIVATOR_FLASHLIGHT_PIN,
ACTIVATOR_TIMEOUT
);
Mast mast(
MAST_SERVO_PIN,
MAST_RAISED_ANGLE,
MAST_LOWERED_ANGLE,
MAST_TIMEOUT
);
Blinkenlights blinkenlights(
BLINKEN_TOP_PIN,
BLINKEN_BOTTOM_PIN,
BLINKEN_FLASHLIGHT_PIN,
BLINKEN_INTERVAL
);
Screen screen(SCREEN_PIN);
ActivatorState aState;
MastState mState;
BlinkenState bState;
ScreenState sState;
boolean shouldToggle;
boolean mastLowered;
void setup()
{
mast.setup();
}
void loop()
{
aState = activator.tick();
if (aState == ACTIVATOR_AIMING || aState == ACTIVATOR_FLASHLIGHT) {
shouldToggle = true;
} else {
shouldToggle = false;
}
mState = mast.tick(shouldToggle);
if (mState == MAST_LOWERED) {
mastLowered = true;
} else {
mastLowered = false;
}
bState = blinkenlights.tick(mastLowered);
sState = screen.tick(mastLowered);
}