Gebruiker:DeGroteEmojii/Kladblok: verschil tussen versies

Uit Wikikids
Naar navigatie springen Naar zoeken springen
Regel 1: Regel 1:
<div class="user-show">[https://wikikids.nl/index.php?title=Speciaal:Aanmelden&returnto=Wikikids:SuperSchrijfwedstrijd_2023/inschrijven&nosummary=true&returntoquery=action%3Dedit%26section%3Dnew%26preload%3DGebruiker%253ADeGroteEmojii%252FInvullen%26editintro%3DGebruiker%253ADeGroteEmojii%252FIntro klik hier]</div>
+
<syntaxhighlight lang="C" line>
<span class = "anonymous-show" style="cursor:not-allowed;color:#a39b9b;">Je moet eerst aangemeld zijn</span>
+
//Yes, I made this myself. I just wanted to see if this is an extension
 +
#include <LiquidCrystal_I2C.h>
 +
 
 +
LiquidCrystal_I2C lcd(0x27, 16, 2); //creates lcd obj. address, x, y
 +
 
 +
//variables
 +
int points[5] = {0, 0, 0, 0, 0};
 +
int index = 0;
 +
int index1 = 0;
 +
bool selection = false;
 +
bool shouldUpdate = true;
 +
 
 +
void setup(){
 +
  //init the lcd and display
 +
  lcd.init();
 +
  lcd.clear();
 +
  lcd.backlight();
 +
  lcd.setCursor(2, 1);
 +
  lcd.print("Door Sipke");
 +
  delay(1000);
 +
  lcd.clear();
 +
}
 +
 
 +
void initPoints(){
 +
  //main loop, counts points
 +
  //yes this is a mess but you can't loop this stuff
 +
  if (shouldUpdate){
 +
  lcd.setCursor(0, 0);
 +
  lcd.print(points[0]);
 +
  lcd.setCursor(13, 0);
 +
  lcd.print(points[1]);
 +
  lcd.setCursor(0, 1);
 +
  lcd.print(points[2]);
 +
  lcd.setCursor(13, 1);
 +
  lcd.print(points[3]);
 +
  lcd.setCursor(7, 0);
 +
  lcd.print(points[4]);}
 +
}
 +
void inputCheck(int pin, int count){
 +
  //counters
 +
  index = digitalRead(pin);
 +
  if (index == HIGH and selection == false and pin == 1 xor pin == 2){
 +
    delay(300);
 +
    points[4] += count;
 +
  }
 +
  //resetting
 +
  if (index == HIGH and selection == false and pin == 3){
 +
    delay(300);
 +
    lcd.setCursor(7, 0);
 +
    lcd.clear();
 +
    points[4] -= points[4];
 +
  }
 +
  //transferring to player
 +
  if (index == HIGH and selection == false and pin == 4){
 +
    delay(300);
 +
    selection = true;
 +
    lcd.setCursor(7, 1);
 +
    lcd.print("Sel");
 +
  }
 +
  for (int i = i; i == 4; i++){
 +
  if (index == HIGH and selection == true and pin == i){
 +
    points[pin - 1] =+ points[4];
 +
    points[4] = 0;
 +
    lcd.clear();
 +
  }
 +
}
 +
}
 +
void loop(){
 +
initPoints();
 +
  inputCheck(1, 1);
 +
  inputCheck(2, 10);
 +
  inputCheck(3, 0);
 +
  inputCheck(4, 0);
 +
}
 +
</syntaxhighlight>

Versie van 7 feb 2023 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}
Afkomstig van Wikikids , de interactieve Nederlandstalige Internet-encyclopedie voor en door kinderen. "https://wikikids.nl/index.php?title=Gebruiker:DeGroteEmojii/Kladblok&oldid=765685"