-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiallerDecoderLCD.ino
68 lines (50 loc) · 1.3 KB
/
diallerDecoderLCD.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
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
bool finalPulse = false;
bool previousState;
int currentState = 13;
unsigned long previousTime = 0;
unsigned long timeElapsed = 0;
unsigned long currentTime;
int digit = 0;
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
lcd.print("EdwardTorpy.com");
lcd.setCursor(0, 1);
pinMode(currentState, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
while(digitalRead(currentState) == LOW){
}
while(digitalRead(currentState) == HIGH){
previousState = HIGH;
previousTime = 0;
finalPulse = false;
}
while(finalPulse == false){
currentTime = millis();
if((digitalRead(currentState) == HIGH)&& (previousState == LOW)) {
previousState = HIGH;
digit++;
}
if((digitalRead(currentState) == LOW) && (previousState == HIGH)){
previousTime = currentTime;
previousState = LOW;
}
if((digitalRead(currentState) == LOW) && (previousState == LOW)){
timeElapsed = currentTime - previousTime;
}
if ((timeElapsed > 400) && (digitalRead(currentState) == LOW)){
finalPulse = true;
digit = digit-1;
if(digit == 10){
digit = 0;
}
lcd.print(digit);
digit = 0;
}
}
delay(500);
}