Gebruiker:DeGroteEmojii/Kladblok: verschil tussen versies

Uit Wikikids
Naar navigatie springen Naar zoeken springen
(Ik haat arduino)
Label: Ongedaan maken
Regel 1: Regel 1:
<syntaxhighlight lang="C" line>
+
<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>
//Yes, I made this myself. I just wanted to see if this is an extension
+
<span class = "anonymous-show" style="cursor:not-allowed;color:#a39b9b;">Je moet eerst aangemeld zijn</span>
#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

Je moet eerst aangemeld zijn

Afkomstig van Wikikids , de interactieve Nederlandstalige Internet-encyclopedie voor en door kinderen. "https://wikikids.nl/index.php?title=Gebruiker:DeGroteEmojii/Kladblok&oldid=765686"