Gebruiker:DeGroteEmojii/Kladblok
< Gebruiker:DeGroteEmojii
Naar navigatie springen
Naar zoeken springen
Versie door DeGroteEmojii (overleg | bijdragen) op 7 feb 2023 om 14:49
1//Yes, I made this myself. I just wanted to see if this is an extension
2#include <LiquidCrystal_I2C.h>
3
4LiquidCrystal_I2C lcd(0x27, 16, 2); //creates lcd obj. address, x, y
5
6//variables
7int points[5] = {0, 0, 0, 0, 0};
8int index = 0;
9int index1 = 0;
10bool selection = false;
11bool shouldUpdate = true;
12
13void setup(){
14 //init the lcd and display
15 lcd.init();
16 lcd.clear();
17 lcd.backlight();
18 lcd.setCursor(2, 1);
19 lcd.print("Door Sipke");
20 delay(1000);
21 lcd.clear();
22}
23
24void initPoints(){
25 //main loop, counts points
26 //yes this is a mess but you can't loop this stuff
27 if (shouldUpdate){
28 lcd.setCursor(0, 0);
29 lcd.print(points[0]);
30 lcd.setCursor(13, 0);
31 lcd.print(points[1]);
32 lcd.setCursor(0, 1);
33 lcd.print(points[2]);
34 lcd.setCursor(13, 1);
35 lcd.print(points[3]);
36 lcd.setCursor(7, 0);
37 lcd.print(points[4]);}
38}
39void inputCheck(int pin, int count){
40 //counters
41 index = digitalRead(pin);
42 if (index == HIGH and selection == false and pin == 1 xor pin == 2){
43 delay(300);
44 points[4] += count;
45 }
46 //resetting
47 if (index == HIGH and selection == false and pin == 3){
48 delay(300);
49 lcd.setCursor(7, 0);
50 lcd.clear();
51 points[4] -= points[4];
52 }
53 //transferring to player
54 if (index == HIGH and selection == false and pin == 4){
55 delay(300);
56 selection = true;
57 lcd.setCursor(7, 1);
58 lcd.print("Sel");
59 }
60 for (int i = i; i == 4; i++){
61 if (index == HIGH and selection == true and pin == i){
62 points[pin - 1] =+ points[4];
63 points[4] = 0;
64 lcd.clear();
65 }
66 }
67}
68void loop(){
69 initPoints();
70 inputCheck(1, 1);
71 inputCheck(2, 10);
72 inputCheck(3, 0);
73 inputCheck(4, 0);
74}