Jak wstawić polskie litery? Jak zrobić menu i jak zrobić aby wyświetlało cyfry w rzucie kostką? Narazie chce jedną grę w tysiąca a potem jak opanuję to Kurnik i Poker.
Kod:
/*-----( Import needed libraries )-----*/
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
#define PRZYCISK0 12
#define PRZYCISK1 11
#define PRZYCISK2 10
#define PRZYCISK3 9
#define PRZYCISK4 8
#define DOWN_KEY 12
#define UP_KEY 11
#define wyswietlacz
int ostatniStan = LOW; //BO PULLUP
int losowaLiczba0;
int losowaLiczba1;
int losowaLiczba2;
int losowaLiczba3;
int losowaLiczba4;
int cyfra;
int r = 0;
int s = 0;
int t = 0;
int z = 0;
int x = 0;
/*-----( Declare Constants )-----*/
// LCD geometry
const int LCD_COLS = 20;
const int LCD_ROWS = 4;
/*-----( Declare objects )-----*/
hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
/*-----( Declare Variables )-----*/
int status;
void setup() /*----( SETUP: RUNS ONCE )----*/
{
status = lcd.begin(LCD_COLS, LCD_ROWS);
if(status) // non zero status means it was unsuccesful
{
// hd44780 has a fatalError() routine that blinks an led if possible
// begin() failed so blink error code using the onboard LED if possible
hd44780::fatalError(status); // does not return
}
Serial.begin(9600);
// Print a message to the LCD.
lcd.setCursor(0, 0);
lcd.print(" Witam Wszystkich");
lcd.setCursor(0, 1);
lcd.print(" Gra w 1000");
lcd.setCursor(0, 2);
lcd.print(" Kenshin Himura");
lcd.setCursor(0, 3);
lcd.print(" MENU");
delay(5000);
}/*--(end setup )---*/
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
{lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Wybor Ilosc Graczy:");
lcd.setCursor(0, 1);
lcd.print("Graczy 2. ");
lcd.setCursor(0, 2);
lcd.print("Graczy 3. ");
lcd.setCursor(0, 3);
lcd.print("Graczy 4. ");
delay(10000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Gracz 1.");
lcd.setCursor(0,1);
lcd.print("Gracz 2.");
lcd.setCursor(0,2 );
lcd.print("Gracz 3.");
lcd.setCursor(0, 3);
lcd.print("Gracz 4.");
r = random(1, 7);
Serial.println(r);
s = random(1, 7);
Serial.println(s);
t = random(1, 7);
Serial.println(t);
Serial.println(r);
z = random(1, 7);
Serial.println();
x = random(1, 7);
Serial.println(x);
delay(1000);
lcd.backlight(); // zalaczenie podswietlenia
// delay(100);
while (digitalRead(PRZYCISK0) == LOW){} {
digitalWrite(PRZYCISK0, LOW);
Serial.print(PRZYCISK0, HIGH);
while (digitalRead(PRZYCISK0) == HIGH){}
digitalWrite(PRZYCISK0, HIGH);
Serial.print(PRZYCISK0, LOW);
while (digitalRead(PRZYCISK1) == LOW){} {
digitalWrite(PRZYCISK1, LOW);
Serial.print(PRZYCISK1, HIGH);
while (digitalRead(PRZYCISK1) == HIGH){}
digitalWrite(PRZYCISK1, HIGH);
Serial.print(PRZYCISK1, LOW);
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Gracz 1.");
lcd.setCursor(0,2);
lcd.print("Rzut koscmi.");
lcd.setCursor(0,3);
lcd.print(" ");
delay(5000);
lcd.setCursor(0, 0);
lcd.print("Gracz 1- ");
lcd.setCursor(0, 1);
lcd.print("Gracz 2- ");
lcd.setCursor(0, 2);
lcd.print("Gracz 3- ");
lcd.setCursor(0, 3);
lcd.print("Gracz 4- ");
lcd.clear();
losowaLiczba0 = random(0, 10);
Serial.println(losowaLiczba0,r);
losowaLiczba1 = random(0,12);
Serial.println(losowaLiczba1);
losowaLiczba1 = random(0,14);
Serial.println(losowaLiczba2);
losowaLiczba3 = random(0,16);
Serial.println(losowaLiczba3);
losowaLiczba4 = random(0,18);
Serial.println(losowaLiczba4);
if (digitalRead(PRZYCISK0) ==LOW) { //wyświetl liczbę tylko, jeśli naciśnięto przycisk
delay(PRZYCISK0);//Czekaj na naciśnięcie przycisku
if (digitalRead(PRZYCISK0) ==LOW) { //wyświetl liczbę tylko, jeśli naciśnięto przycisk
delay(PRZYCISK0);//Czekaj na naciśnięcie przycisku
wyswietlacz(losowaLiczba0); //Wyswietl wartosc na wyswietlaczu
wyswietlacz(losowaLiczba1); //Wyswietl wartosc na wyswietlaczu
wyswietlacz(losowaLiczba2); //Wyswietl wartosc na wyswietlaczu
wyswietlacz(losowaLiczba3); //Wyswietl wartosc na wyswietlaczu
wyswietlacz(losowaLiczba4); //Wyswietl wartosc na wyswietlaczu
delay(5000);
lcd.setCursor(0,1);
lcd.print("Kosci: 1 2 3 4 5");
lcd.setCursor(0,2);
lcd.print("Oczka: ");
lcd.setCursor(0,4);
lcd.print("Punkty: ");
lcd.setCursor(1,6);
lcd.print("");
lcd.setCursor(1,8);
lcd.print("");
lcd.setCursor(1,10);
lcd.print("");
}
}
}
}
}
}/* --(end main loop )-- */
/*-----( Declare User-written Functions )-----*/
/* ( THE END ) */