-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMintSensorTest.ino
More file actions
36 lines (27 loc) · 875 Bytes
/
MintSensorTest.ino
File metadata and controls
36 lines (27 loc) · 875 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
const int mintSensorPin = 2; // changed to 2 because it is usable for interrupt also make sure to use a digital pin
volatile int mintCount = 0; // start this at zero in order to count
volatile byte state = LOW; // idk what this does
void setup() {
Serial.begin(9600);
pinMode(mintSensorPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(mintSensorPin), incrementMintCount, FALLING); // (maps pin to correct interrupt pin, calls ISR function, when to do it [HIGH TO LOW])
}
void loop() {
int mintSensorRead = digitalRead(mintSensorPin);
if (mintSensorRead) {
Serial.println("All clear");
Serial.println(mintSensorRead);
}
else
{
Serial.println("Blocked");
Serial.println(mintSensorRead);
}
delay(500);
Serial.print("Mint count: ");
Serial.println(mintCount);
delay(500);
}
void incrementMintCount() {
mintCount++;
}