-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenCashDrawer.ino
More file actions
54 lines (46 loc) · 836 Bytes
/
OpenCashDrawer.ino
File metadata and controls
54 lines (46 loc) · 836 Bytes
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
#define KEY_LEFT_CTRL 0x01
#define KEY_RIGHT_CTRL 0x10
uint8_t buf[8] = { 0 };
#define PIN_COPY 5
#define DrawerKey 6
int state = 1;
int start = 0;
void setup()
{
Serial.begin(9600);
pinMode(PIN_COPY, INPUT);
pinMode(DrawerKey,OUTPUT);
digitalWrite(PIN_COPY, 1);
digitalWrite(DrawerKey,0);
delay(10);
}
void loop()
{
state = digitalRead(PIN_COPY);
if (state != 1 && start == 0) {
start = 1;
buf[0] = KEY_LEFT_CTRL;
buf[2] = 0;
Serial.write(buf, 8);
OpenDrawer();
releaseKey();
}
if(state == 1 and start == 1){
start = 0;
}
}
void releaseKey()
{
delay(50);
buf[0] = 0;
buf[2] = 0;
Serial.write(buf, 8); // Release key
digitalWrite(DrawerKey,0);
delay(200);
}
void OpenDrawer(){
digitalWrite(DrawerKey,1);
delay(50);
digitalWrite(DrawerKey,0);
delay(200);
}