-
Notifications
You must be signed in to change notification settings - Fork 3
/
NV10_Billreader.ino
94 lines (80 loc) · 2.25 KB
/
NV10_Billreader.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
#define NoteAcceptor Serial3
/*
* control a NV10 Bank Note Validating System with a Arduino Mega 2560
* NV10 PIN 1 (RS232) Tx <-> Arduino Serial3 Rx 15
* NV10 PIN 5 (RS232) Rx <-> Arduino Serial3 Tx 14
* Make sure both grounds (NV 10 PIN 16 <-> Arduino GND) are connected
* Documentation https://www.coinoperatorshop.com/media/products/NV10%20Manual%20Deutsch.pdf
* page 16 shows the messages which can be send and received
*/
byte noteInEscrow = 0;
int credit = 0;
byte channelValues[] = {5, 10, 20};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
NoteAcceptor.begin(300, SERIAL_8N2);
pinMode(15, INPUT_PULLUP);
NoteAcceptor.write(184);
NoteAcceptor.write(170);
NoteAcceptor.write(191);
}
void loop() {
// put your main code here, to run repeatedly:
if (NoteAcceptor.available()){
byte byteIn = NoteAcceptor.read();
Serial.print("**IN-");
Serial.print(byteIn);
Serial.println("**");
if (byteIn >= 1 && byteIn <= 3){
if (noteInEscrow){
Serial.println("Escrow accepted");
credit = credit + channelValues[byteIn - 1];
Serial.print("Credit: €");
Serial.println(credit);
noteInEscrow = 0;
}else{
Serial.print("€");
Serial.print(channelValues[byteIn - 1]);
Serial.println(" in escrow");
Serial.println("Accept 'Y' or 'N'");
noteInEscrow = byteIn;
}
}
if (byteIn == 70){
Serial.println("Abort from escrow");
noteInEscrow = 0;
}
}
if (Serial.available()){
byte byteIn = Serial.read();
if (byteIn == 'Y'){
NoteAcceptor.write(172);
Serial.println("Accept");
}
if (byteIn == 'N'){
NoteAcceptor.write(173);
Serial.println("Decline");
}
if (byteIn == 'R'){
credit = 0;
Serial.println("Credit reset.");
}
if (byteIn == 'E'){
NoteAcceptor.write(184);
Serial.println("Acceptor enabled");
}
if (byteIn == 'D'){
NoteAcceptor.write(185);
Serial.println("Acceptor Disabled");
}
if (byteIn == 'M'){
NoteAcceptor.write(170);
Serial.println("Enable serial escrow mode");
}
if (byteIn == 'S'){
NoteAcceptor.write(182);
Serial.println("Status");
}
}
}