-
Notifications
You must be signed in to change notification settings - Fork 0
/
BT_TableControl.ino
70 lines (52 loc) · 1.04 KB
/
BT_TableControl.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 "Communication.h"
#define BUTTON_UP 6
#define BUTTON_DOWN 5
CommunicationClass communication;
String recivedMessage;
String COMMAND_UP = "UP";
String COMMAND_DOWN = "DN";
unsigned long timer_ResetComndDelay = 0;
void setup()
{
Serial.begin(9600);
pinMode(BUTTON_UP, OUTPUT);
pinMode(BUTTON_DOWN, OUTPUT);
}
void loop()
{
// Recive message
recivedMessage = communication.ReadBytesUntil();
// Execute Command
if (recivedMessage == COMMAND_UP)
{
Serial.println("EXEC: UP");
MoveUp();
timer_ResetComndDelay = millis();
}
else if (recivedMessage == COMMAND_DOWN)
{
Serial.println("EXEC: DOWN");
MoveDown();
timer_ResetComndDelay = millis();
}
else if (recivedMessage == "") {
Reset();
}
// Execute Timer
// - blink and play sound
// - cancel timer if user pushes buttons breaks
}
void Reset() {
if (millis() - timer_ResetComndDelay > 12UL) {
digitalWrite(BUTTON_UP, HIGH);
digitalWrite(BUTTON_DOWN, HIGH);
}
}
void MoveUp()
{
digitalWrite(BUTTON_UP, LOW);
}
void MoveDown()
{
digitalWrite(BUTTON_DOWN, LOW);
}