#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
int check2 = 0;
int check1 = 0;
int mode = 0; // Variable to keep track of the current mode
int players = 2; // Variable to keep track of the number of players (default: 2)
const int button1 = 6; // Button 1 connected to digital pin 2
const int button2 = 9; // Button 2 connected to digital pin 3
void durak(){
if(players == 2){
display.clearDisplay();
display.setCursor((SCREEN_WIDTH - 120) / 2, (SCREEN_HEIGHT - 40) / 2);
display.println("init durak 2p");
display.display();
}
}
void setup() {
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.display();
delay(1000);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor((SCREEN_WIDTH - 12 * 6) / 2, (SCREEN_HEIGHT - 40) / 2);
display.print("Choose");
display.setCursor((SCREEN_WIDTH - 12 * 6) / 2, (SCREEN_HEIGHT - 2) / 2);
display.print("a game");
display.display();
delay(1000);
display.clearDisplay();
display.display();
}
void loop() {
if (mode == 0) {
display.setTextSize(2);
display.clearDisplay();
display.setCursor((SCREEN_WIDTH - 66) / 2, (SCREEN_HEIGHT - 40) / 2);
display.println("Durak");
display.display();
mode = 1;
delay(1000);
}
else if (mode == 1) {
if (digitalRead(button1) == LOW && check1 == 0) {
display.clearDisplay();
display.setCursor((SCREEN_WIDTH - 12 * 6) / 2, (SCREEN_HEIGHT - 40) / 2);
display.print("Classic Poker");
display.display();
mode = 2;
delay(1000);
}
else if(digitalRead(button2) == LOW && check2 == 0) {
check2 = 1;
check1 = 1;
display.clearDisplay();
display.setTextSize(2);
display.setCursor((SCREEN_WIDTH - 12 * 6) / 2, (SCREEN_HEIGHT - 60) / 2);
display.print("number");
display.setCursor((SCREEN_WIDTH - 120) / 2, (SCREEN_HEIGHT - 10) / 2);
display.print("of players");
display.display();
delay(2000);
display.clearDisplay();
display.setCursor((SCREEN_WIDTH - 10) / 2, (SCREEN_HEIGHT - 10) / 2);
display.print(players);
display.display();
do{
if(digitalRead(button2) == LOW && check2 == 1) {
players ++;
if (players>6){
players = 2;}
display.clearDisplay();
display.setCursor((SCREEN_WIDTH - 10) / 2, (SCREEN_HEIGHT - 10) / 2);
display.print(players);
display.display();
delay(1000);
}
}while(digitalRead(button1) != LOW);
durak();
}
}
else if (mode == 2) {
if (digitalRead(button1) == LOW && check1 == 0) {
display.setTextSize(2);
display.clearDisplay();
display.setCursor((SCREEN_WIDTH - 12 * 6) / 2, (SCREEN_HEIGHT - 40) / 2);
display.print("Texas Hold'em");
display.display();
delay(1000);
mode = 3;
}
}
else if (mode == 3) {
if (digitalRead(button1) == LOW && check1 == 0) {
mode = 0;
}
}
}
//