Hi, I have an Arduino nano, 3x4 Button Pad and a 2004 LCD. I want to make a guessing game (with numbers) up to 4 players. But I ran into problems while coding. Actually I just started. Here is the Code I got
#include <SoftPathElectronics.h>
CustomKeyboard keyboard;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
//Variablen
int player_n;
void setup() {
// Setup Keyboard
Serial.begin(115200);
String key = "3 12 6 1 1022 315 186 511 241 158 340 195 136 255 164 120 0 0 0 0";
keyboard.setupKey(key);
// Setup LCD
lcd.init();
lcd.backlight();
// Oyda
lcd.setCursor(3, 1);
lcd.print("Willkommen bei");
lcd.setCursor(4, 2);
lcd.print("Trivia Guess");
}
void loop() {
int key = keyboard.getKeyPressed();
if (key > 0) {
lcd.clear();
lcd.setCursor(2,1);
lcd.print("Spieleranzahl:");
lcd.blink();
delay(100);
}
}
As you can see, the keyboard uses a custom Library. If you push a button, u can read a key from 1 to 12. All I got for now is a welcome screen and if you push any button, u can read "player count:" and now u should be able to enter a number between 1 & 4 and then push enter to start the game.
Now, how do I put this function in the void loop()? I can't figure out a right trigger, because if you press a key, the int = key stays this key as long until you push another button. This causes unlimited triggers in the loop sometimes ![]()
pls help im dying