-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDrinking_Die.ino
67 lines (44 loc) · 1023 Bytes
/
Drinking_Die.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
//Viktor Goleš 20.11.2020.
#include <Servo.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
Servo servo;
const int button = 2;
int lastButtonState;
int currentButtonState;
int choice;
void printChoice(int choice)
{
if(choice == 1) {
Serial.println("CUGAJ");
lcd.print("CUGAS");
} else {
Serial.println("DIJELIS");
lcd.print("DIJELIS");
}
}
void setup() {
Serial.begin(9600);
pinMode(button, INPUT_PULLUP);
lcd.begin(16, 2);
servo.attach(5);
servo.write(0);
currentButtonState = digitalRead(button);
lcd.print("Kocka sudbine");
}
void loop() {
lastButtonState = currentButtonState;
currentButtonState = digitalRead(button);
if(lastButtonState == HIGH && currentButtonState == LOW) {
lcd.clear();
servo.write(100);
delay(700);
servo.write(0);
choice = random(2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Kocka zeli da:");
lcd.setCursor(0, 1);
printChoice(choice);
}
}