//saimonsays
#include "simonGame.h"
#include "pitches.h"
#include <Wire.h>
//keypad
#include <Keypad.h>
const byte ROWS = 4; // four rows
const byte COLS = 4; // four columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {22, 23, 24, 25}; // connect to the row pinouts of the keypad
byte colPins[COLS] = {26, 27, 28, 29}; // connect to the column pinouts of the keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
int level = 0;
int score = 0;
char expectedKey;
bool isPlaying = true;
//animation
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "animation.h"
#define SCREEN_I2C_ADDR 0x3C // or 0x3C
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RST_PIN -1 // Reset pin (-1 if not available)
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST_PIN);
// OLED Animation: edit
// Code auto-generated by https://wokwi.com/animator, graphics by icons8.com
#define FRAME_DELAY (42) // Delay between frames
#define FRAME_WIDTH (48) // Width of animation frames
#define FRAME_HEIGHT (48) // Height of animation frames
#define FRAME_COUNT (sizeof(frames) / sizeof(frames[0]))
const byte PROGMEM frames[][288] = {
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,240,0,0,0,0,3,248,0,0,0,0,3,252,0,0,0,0,1,252,0,0,0,0,24,252,0,0,0,0,56,124,0,0,0,0,112,60,0,0,0,0,224,24,0,0,0,1,192,0,0,0,0,3,128,192,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,12,7,0,0,0,0,30,14,0,0,0,0,31,28,0,0,0,0,31,184,0,0,0,0,31,240,0,0,0,0,63,224,0,0,0,0,63,128,0,0,0,0,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,240,0,0,0,0,3,248,0,0,0,0,3,252,0,0,0,0,1,252,0,0,0,0,24,252,0,0,0,0,56,124,0,0,0,0,112,60,0,0,0,0,224,24,0,0,0,1,192,0,0,0,0,3,128,192,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,12,7,0,0,0,0,30,14,0,0,0,0,31,28,0,0,0,0,31,184,0,0,0,0,31,240,0,0,0,0,63,224,0,0,0,0,63,128,0,0,0,0,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,240,0,0,0,0,3,248,0,0,0,0,3,252,0,0,0,0,1,252,0,0,0,0,24,252,0,0,0,0,56,124,0,0,0,0,112,60,0,0,0,0,224,24,0,0,0,1,192,0,0,0,0,3,128,192,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,12,7,0,0,0,0,30,14,0,0,0,0,31,28,0,0,0,0,31,184,0,0,0,0,31,240,0,0,0,0,63,224,0,0,0,0,63,128,0,0,0,0,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,240,0,0,0,0,3,248,0,0,0,0,3,252,0,0,0,0,1,252,0,0,0,0,24,252,0,0,0,0,56,124,0,0,0,0,112,60,0,0,0,0,224,24,0,0,0,1,192,0,0,0,0,3,128,192,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,12,7,0,0,0,0,30,14,0,0,0,0,31,28,0,0,0,0,31,184,0,0,0,0,31,240,0,0,0,0,63,224,0,0,0,0,63,128,0,0,0,0,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,224,0,0,0,0,7,240,0,0,0,0,7,248,0,0,0,0,3,248,0,0,0,0,49,248,0,0,0,0,112,248,0,0,0,0,224,120,0,0,0,1,192,48,0,0,0,3,128,0,0,0,0,7,0,128,0,0,0,14,1,128,0,0,0,28,3,0,0,0,0,56,6,0,0,0,0,112,12,0,0,0,0,224,24,0,0,0,1,192,48,0,0,0,3,128,96,0,0,0,7,0,192,0,0,0,14,1,128,0,0,0,28,3,0,0,0,0,56,6,0,0,0,0,112,12,0,0,0,0,224,24,0,0,0,1,192,48,0,0,0,3,128,96,0,0,0,7,0,192,0,0,0,14,1,128,0,0,0,28,3,0,0,0,0,56,6,0,0,0,0,112,12,0,0,0,0,224,24,0,0,0,1,192,48,0,0,0,3,128,96,0,0,0,7,0,192,0,0,0,14,1,128,0,0,0,28,3,0,0,0,0,24,6,0,0,0,0,28,12,0,0,0,0,30,24,0,0,0,0,63,48,0,0,0,0,63,224,0,0,0,0,63,192,0,0,0,0,127,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,31,128,0,0,0,0,63,192,0,0,0,0,31,224,0,0,0,0,143,224,0,0,0,1,199,224,0,0,0,3,131,224,0,0,0,7,1,192,0,0,0,14,0,128,0,0,0,28,0,0,0,0,0,56,6,0,0,0,0,112,12,0,0,0,0,96,24,0,0,0,0,192,48,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,24,7,0,0,0,0,48,14,0,0,0,0,96,28,0,0,0,0,192,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,3,0,0,0,0,56,6,0,0,0,0,48,12,0,0,0,0,56,24,0,0,0,0,60,48,0,0,0,0,126,96,0,0,0,0,127,192,0,0,0,0,127,192,0,0,0,0,126,0,0,0,0,0,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,62,0,0,0,0,0,127,0,0,0,0,0,127,128,0,0,0,0,63,128,0,0,0,3,31,192,0,0,0,3,15,128,0,0,0,6,3,128,0,0,0,12,1,0,0,0,0,24,0,0,0,0,0,48,12,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,1,128,0,0,0,28,3,0,0,0,0,24,6,0,0,0,0,48,12,0,0,0,0,96,24,0,0,0,0,192,48,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,24,0,0,0,1,192,48,0,0,0,1,128,96,0,0,0,3,0,192,0,0,0,6,1,128,0,0,0,12,3,0,0,0,0,24,7,0,0,0,0,24,14,0,0,0,0,60,28,0,0,0,0,62,56,0,0,0,0,63,112,0,0,0,0,63,224,0,0,0,0,63,192,0,0,0,0,126,0,0,0,0,0,120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,63,128,0,0,0,0,127,192,0,0,0,0,63,192,0,0,0,1,143,192,0,0,0,3,135,192,0,0,0,7,3,128,0,0,0,14,1,128,0,0,0,12,0,0,0,0,0,24,4,0,0,0,0,48,12,0,0,0,0,112,24,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,3,0,192,0,0,0,6,1,128,0,0,0,12,3,0,0,0,0,28,6,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,96,56,0,0,0,0,192,48,0,0,0,1,128,96,0,0,0,3,128,192,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,24,14,0,0,0,0,48,12,0,0,0,0,96,24,0,0,0,0,224,48,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,3,1,192,0,0,0,3,3,128,0,0,0,7,131,0,0,0,0,7,230,0,0,0,0,7,252,0,0,0,0,7,252,0,0,0,0,7,240,0,0,0,0,63,128,0,0,0,0,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,128,0,0,0,0,15,224,0,0,0,0,31,224,0,0,0,0,15,240,0,0,0,0,71,240,0,0,0,0,99,240,0,0,0,0,192,224,0,0,0,1,192,96,0,0,0,3,128,0,0,0,0,3,1,0,0,0,0,6,3,0,0,0,0,14,7,0,0,0,0,28,6,0,0,0,0,24,12,0,0,0,0,48,28,0,0,0,0,96,56,0,0,0,0,224,48,0,0,0,0,192,96,0,0,0,1,128,224,0,0,0,3,1,192,0,0,0,7,1,128,0,0,0,6,3,0,0,0,0,12,6,0,0,0,0,24,14,0,0,0,0,56,12,0,0,0,0,48,24,0,0,0,0,96,48,0,0,0,0,192,112,0,0,0,1,192,96,0,0,0,1,128,192,0,0,0,3,1,128,0,0,0,6,3,128,0,0,0,14,3,0,0,0,0,12,6,0,0,0,0,24,12,0,0,0,0,24,28,0,0,0,0,30,24,0,0,0,0,63,48,0,0,0,0,63,224,0,0,0,0,63,224,0,0,0,0,63,128,0,0,0,63,254,0,0,0,0,63,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,240,0,0,0,0,3,248,0,0,0,0,7,252,0,0,0,0,3,252,0,0,0,0,8,252,0,0,0,0,24,124,0,0,0,0,56,24,0,0,0,0,48,0,0,0,0,0,96,0,0,0,0,0,224,96,0,0,0,0,192,96,0,0,0,1,192,192,0,0,0,3,129,192,0,0,0,3,1,128,0,0,0,7,3,0,0,0,0,6,7,0,0,0,0,12,6,0,0,0,0,28,12,0,0,0,0,24,12,0,0,0,0,48,24,0,0,0,0,112,56,0,0,0,0,96,48,0,0,0,0,224,96,0,0,0,0,192,224,0,0,0,1,128,192,0,0,0,3,129,128,0,0,0,3,1,128,0,0,0,6,3,0,0,0,0,14,7,0,0,0,0,12,6,0,0,0,0,28,12,0,0,0,0,24,28,0,0,0,0,48,24,0,0,0,0,112,48,0,0,0,0,96,112,0,0,0,0,112,96,0,0,0,0,120,192,0,0,0,0,126,192,0,0,0,0,127,128,0,0,0,0,127,0,0,0,0,0,126,0,0,0,63,255,248,0,0,0,63,255,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,0,0,0,0,1,252,0,0,0,0,3,252,0,0,0,0,3,254,0,0,0,0,1,254,0,0,0,0,4,126,0,0,0,0,12,30,0,0,0,0,12,0,0,0,0,0,28,0,0,0,0,0,24,24,0,0,0,0,56,24,0,0,0,0,48,48,0,0,0,0,48,48,0,0,0,0,96,96,0,0,0,0,96,96,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,1,129,192,0,0,0,1,129,128,0,0,0,3,3,128,0,0,0,3,3,0,0,0,0,6,3,0,0,0,0,6,6,0,0,0,0,12,6,0,0,0,0,12,12,0,0,0,0,28,12,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,48,48,0,0,0,0,48,48,0,0,0,0,96,96,0,0,0,0,96,96,0,0,0,0,192,224,0,0,0,0,192,192,0,0,0,1,129,192,0,0,0,1,129,128,0,0,0,1,193,128,0,0,0,1,243,0,0,0,0,1,255,0,0,0,0,1,254,0,0,0,0,1,252,0,0,0,0,1,248,0,0,63,255,255,224,0,0,63,255,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,1,248,0,0,0,0,3,252,0,0,0,0,3,252,0,0,0,0,7,254,0,0,0,0,1,254,0,0,0,0,4,60,0,0,0,0,12,0,0,0,0,0,12,0,0,0,0,0,12,8,0,0,0,0,12,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,48,0,0,0,0,48,48,0,0,0,0,48,48,0,0,0,0,48,48,0,0,0,0,48,96,0,0,0,0,96,96,0,0,0,0,96,96,0,0,0,0,96,96,0,0,0,0,96,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,193,128,0,0,0,1,129,128,0,0,0,1,129,128,0,0,0,1,129,128,0,0,0,1,131,0,0,0,0,3,3,0,0,0,0,3,3,0,0,0,0,3,6,0,0,0,0,6,6,0,0,0,0,6,6,0,0,0,0,6,6,0,0,0,0,6,12,0,0,0,0,12,12,0,0,0,0,15,140,0,0,0,0,7,248,0,0,0,0,7,248,0,0,0,0,7,240,0,0,0,0,7,224,0,0,0,0,3,192,0,63,255,255,255,128,0,63,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,240,0,0,0,0,7,248,0,0,0,0,15,248,0,0,0,0,15,248,0,0,0,0,15,248,0,0,0,0,0,56,0,0,0,0,12,0,0,0,0,0,12,0,0,0,0,0,12,24,0,0,0,0,8,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,16,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,16,48,0,0,0,0,48,48,0,0,0,0,48,48,0,0,0,0,48,48,0,0,0,0,48,32,0,0,0,0,48,96,0,0,0,0,48,96,0,0,0,0,48,96,0,0,0,0,48,96,0,0,0,0,96,96,0,0,0,0,96,96,0,0,0,0,96,96,0,0,0,0,96,96,0,0,0,0,96,64,0,0,0,0,96,192,0,0,0,0,96,192,0,0,0,0,96,192,0,0,0,0,96,192,0,0,0,0,127,192,0,0,0,0,127,128,0,0,0,0,63,128,0,0,0,0,63,0,0,0,0,0,30,0,0,0,0,0,30,0,63,255,255,255,252,0,63,255,255,255,248,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,192,0,0,0,0,7,240,0,0,0,0,15,240,0,0,0,0,15,248,0,0,0,0,15,248,0,0,0,0,15,248,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,8,24,0,0,0,0,8,24,0,0,0,0,8,24,0,0,0,0,8,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,16,0,0,0,0,24,16,0,0,0,0,24,16,0,0,0,0,24,16,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,31,240,0,0,0,0,15,240,0,0,0,0,15,224,0,0,0,0,7,192,0,0,0,0,7,192,0,0,0,0,3,128,63,255,255,255,255,128,63,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,192,0,0,0,0,7,240,0,0,0,0,15,240,0,0,0,0,15,248,0,0,0,0,15,248,0,0,0,0,15,248,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,12,24,0,0,0,0,15,248,0,0,0,0,7,240,0,0,0,0,7,240,0,0,0,0,3,224,0,0,0,0,3,192,0,0,0,0,1,192,63,255,255,255,255,128,63,255,255,255,255,128,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,192,0,0,0,0,15,224,0,0,0,0,15,240,0,0,0,0,31,240,0,0,0,0,31,240,0,0,0,0,31,240,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,24,16,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,24,48,0,0,0,0,16,48,0,0,0,0,16,48,0,0,0,0,16,48,0,0,0,0,48,48,0,0,0,0,48,48,0,0,0,0,56,48,0,0,0,0,31,240,0,0,0,0,31,224,0,0,0,0,15,192,0,0,0,0,15,192,0,0,0,0,7,128,0,0,0,0,7,128,0,255,255,255,255,128,0,255,255,255,255,128,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,192,0,0,0,0,15,224,0,0,0,0,31,240,0,0,0,0,31,240,0,0,0,0,31,240,0,0,0,0,1,240,0,0,0,0,16,0,0,0,0,0,48,0,0,0,0,0,48,32,0,0,0,0,48,32,0,0,0,0,48,96,0,0,0,0,48,96,0,0,0,0,48,96,0,0,0,0,48,96,0,0,0,0,96,96,0,0,0,0,96,96,0,0,0,0,96,96,0,0,0,0,96,96,0,0,0,0,96,64,0,0,0,0,96,192,0,0,0,0,96,192,0,0,0,0,96,192,0,0,0,0,96,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,193,128,0,0,0,0,193,128,0,0,0,0,193,128,0,0,0,0,193,128,0,0,0,0,129,128,0,0,0,1,129,128,0,0,0,1,129,128,0,0,0,1,129,128,0,0,0,1,129,0,0,0,0,1,255,0,0,0,0,0,255,0,0,0,0,0,254,0,0,0,0,0,254,0,0,0,0,0,124,0,0,0,0,0,120,0,0,0,7,255,255,128,0,0,7,255,255,128,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,192,0,0,0,0,15,224,0,0,0,0,31,240,0,0,0,0,31,240,0,0,0,0,15,240,0,0,0,0,1,240,0,0,0,0,48,48,0,0,0,0,48,0,0,0,0,0,32,32,0,0,0,0,96,96,0,0,0,0,96,96,0,0,0,0,96,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,193,128,0,0,0,1,129,128,0,0,0,1,129,128,0,0,0,1,131,0,0,0,0,3,3,0,0,0,0,3,3,0,0,0,0,3,3,0,0,0,0,3,6,0,0,0,0,6,6,0,0,0,0,6,6,0,0,0,0,6,12,0,0,0,0,12,12,0,0,0,0,12,12,0,0,0,0,12,12,0,0,0,0,12,24,0,0,0,0,24,24,0,0,0,0,24,24,0,0,0,0,24,48,0,0,0,0,48,48,0,0,0,0,48,48,0,0,0,0,48,48,0,0,0,0,56,96,0,0,0,0,63,224,0,0,0,0,63,224,0,0,0,0,31,192,0,0,0,0,31,128,0,0,0,0,31,0,0,0,0,0,30,63,128,0,0,0,12,127,128,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,128,0,0,0,0,15,192,0,0,0,0,31,224,0,0,0,0,31,240,0,0,0,0,15,240,0,0,0,0,35,240,0,0,0,0,96,224,0,0,0,0,96,32,0,0,0,0,192,0,0,0,0,0,192,192,0,0,0,1,192,192,0,0,0,1,129,128,0,0,0,3,129,128,0,0,0,3,3,0,0,0,0,7,3,0,0,0,0,6,6,0,0,0,0,6,6,0,0,0,0,12,12,0,0,0,0,12,12,0,0,0,0,24,28,0,0,0,0,24,24,0,0,0,0,48,56,0,0,0,0,48,48,0,0,0,0,96,112,0,0,0,0,96,96,0,0,0,0,192,96,0,0,0,0,192,192,0,0,0,1,192,192,0,0,0,1,129,128,0,0,0,3,129,128,0,0,0,3,3,0,0,0,0,3,3,0,0,0,0,6,6,0,0,0,0,6,6,0,0,0,0,12,12,0,0,0,0,12,12,0,0,0,0,12,28,0,0,0,0,15,152,0,0,0,0,15,248,0,0,0,0,15,240,0,0,0,0,15,224,0,0,0,0,15,128,0,0,0,0,15,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,128,0,0,0,0,63,192,0,0,0,0,63,192,0,0,0,0,31,224,0,0,0,0,15,224,0,0,0,0,195,192,0,0,0,1,129,192,0,0,0,1,128,0,0,0,0,3,0,0,0,0,0,7,3,0,0,0,0,6,7,0,0,0,0,12,6,0,0,0,0,28,12,0,0,0,0,24,28,0,0,0,0,48,24,0,0,0,0,112,56,0,0,0,0,96,48,0,0,0,0,192,96,0,0,0,0,192,224,0,0,0,1,128,192,0,0,0,3,129,128,0,0,0,3,3,128,0,0,0,6,3,0,0,0,0,14,6,0,0,0,0,12,14,0,0,0,0,24,12,0,0,0,0,24,28,0,0,0,0,48,24,0,0,0,0,112,48,0,0,0,0,96,112,0,0,0,0,192,96,0,0,0,1,192,192,0,0,0,1,129,192,0,0,0,3,1,128,0,0,0,3,3,128,0,0,0,7,3,0,0,0,0,7,198,0,0,0,0,7,238,0,0,0,0,7,252,0,0,0,0,7,248,0,0,0,0,7,224,0,0,0,0,7,128,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,62,0,0,0,0,0,127,0,0,0,0,0,127,128,0,0,0,0,63,128,0,0,0,1,31,128,0,0,0,3,15,128,0,0,0,7,3,128,0,0,0,6,1,0,0,0,0,12,0,0,0,0,0,28,12,0,0,0,0,56,12,0,0,0,0,48,24,0,0,0,0,96,56,0,0,0,0,192,112,0,0,0,1,192,96,0,0,0,1,128,192,0,0,0,3,1,192,0,0,0,6,3,128,0,0,0,14,3,0,0,0,0,12,6,0,0,0,0,24,14,0,0,0,0,48,28,0,0,0,0,112,24,0,0,0,0,96,48,0,0,0,0,192,112,0,0,0,1,128,224,0,0,0,3,128,192,0,0,0,3,1,128,0,0,0,6,3,128,0,0,0,12,7,0,0,0,0,28,6,0,0,0,0,56,12,0,0,0,0,48,28,0,0,0,0,96,56,0,0,0,0,224,48,0,0,0,0,224,96,0,0,0,0,240,224,0,0,0,0,253,192,0,0,0,0,255,128,0,0,0,0,255,0,0,0,0,0,252,0,0,0,0,0,240,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,62,0,0,0,0,0,127,0,0,0,0,0,127,128,0,0,0,0,63,128,0,0,0,3,31,128,0,0,0,3,15,128,0,0,0,6,7,128,0,0,0,12,1,0,0,0,0,28,0,0,0,0,0,56,12,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,0,192,48,0,0,0,1,128,96,0,0,0,3,0,192,0,0,0,7,1,128,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,24,14,0,0,0,0,48,12,0,0,0,0,96,24,0,0,0,0,224,48,0,0,0,1,192,96,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,6,3,128,0,0,0,12,3,0,0,0,0,24,6,0,0,0,0,56,12,0,0,0,0,112,24,0,0,0,0,224,56,0,0,0,0,192,112,0,0,0,1,128,224,0,0,0,3,0,192,0,0,0,6,1,128,0,0,0,7,3,0,0,0,0,7,134,0,0,0,0,7,206,0,0,0,0,15,252,0,0,0,0,15,248,0,0,0,0,15,224,0,0,0,0,15,128,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,31,128,0,0,0,0,63,192,0,0,0,0,63,192,0,0,0,0,31,192,0,0,0,1,143,192,0,0,0,3,131,192,0,0,0,7,1,192,0,0,0,14,0,128,0,0,0,28,0,0,0,0,0,56,6,0,0,0,0,48,12,0,0,0,0,96,24,0,0,0,0,192,48,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,48,0,0,0,1,128,96,0,0,0,3,0,192,0,0,0,6,1,128,0,0,0,12,3,0,0,0,0,24,7,0,0,0,0,48,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,12,3,0,0,0,0,28,6,0,0,0,0,30,12,0,0,0,0,31,24,0,0,0,0,31,176,0,0,0,0,31,224,0,0,0,0,63,192,0,0,0,0,62,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,128,0,0,0,0,15,192,0,0,0,0,15,224,0,0,0,0,15,240,0,0,0,0,103,240,0,0,0,0,227,240,0,0,0,1,193,240,0,0,0,3,128,224,0,0,0,7,0,64,0,0,0,14,1,0,0,0,0,28,3,0,0,0,0,56,6,0,0,0,0,48,12,0,0,0,0,96,28,0,0,0,0,192,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,24,7,0,0,0,0,48,14,0,0,0,0,96,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,0,192,0,0,0,14,1,128,0,0,0,28,3,0,0,0,0,28,6,0,0,0,0,28,12,0,0,0,0,31,24,0,0,0,0,63,176,0,0,0,0,63,224,0,0,0,0,63,192,0,0,0,0,63,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,224,0,0,0,0,7,240,0,0,0,0,7,248,0,0,0,0,3,248,0,0,0,0,49,248,0,0,0,0,112,248,0,0,0,0,224,120,0,0,0,1,192,48,0,0,0,3,128,16,0,0,0,7,0,128,0,0,0,14,1,128,0,0,0,28,3,128,0,0,0,56,7,0,0,0,0,112,14,0,0,0,0,224,28,0,0,0,0,192,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,24,7,0,0,0,0,48,14,0,0,0,0,96,28,0,0,0,0,192,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,24,7,0,0,0,0,48,14,0,0,0,0,96,28,0,0,0,0,192,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,28,7,0,0,0,0,30,14,0,0,0,0,31,28,0,0,0,0,31,184,0,0,0,0,63,240,0,0,0,0,63,224,0,0,0,0,63,0,0,0,0,0,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,240,0,0,0,0,3,248,0,0,0,0,3,252,0,0,0,0,1,252,0,0,0,0,24,252,0,0,0,0,56,124,0,0,0,0,112,60,0,0,0,0,224,24,0,0,0,1,192,0,0,0,0,3,128,192,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,12,7,0,0,0,0,30,14,0,0,0,0,31,28,0,0,0,0,31,184,0,0,0,0,31,240,0,0,0,0,63,224,0,0,0,0,63,128,0,0,0,0,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,240,0,0,0,0,3,248,0,0,0,0,3,252,0,0,0,0,1,252,0,0,0,0,24,252,0,0,0,0,56,124,0,0,0,0,112,60,0,0,0,0,224,24,0,0,0,1,192,0,0,0,0,3,128,192,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,12,7,0,0,0,0,30,14,0,0,0,0,31,28,0,0,0,0,31,184,0,0,0,0,31,240,0,0,0,0,63,224,0,0,0,0,63,128,0,0,0,0,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,240,0,0,0,0,3,248,0,0,0,0,3,252,0,0,0,0,1,252,0,0,0,0,24,252,0,0,0,0,56,124,0,0,0,0,112,60,0,0,0,0,224,24,0,0,0,1,192,0,0,0,0,3,128,192,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,192,112,0,0,0,3,128,224,0,0,0,7,1,192,0,0,0,14,3,128,0,0,0,28,7,0,0,0,0,56,14,0,0,0,0,112,28,0,0,0,0,224,56,0,0,0,1,128,112,0,0,0,3,0,224,0,0,0,6,1,192,0,0,0,12,3,128,0,0,0,12,7,0,0,0,0,30,14,0,0,0,0,31,28,0,0,0,0,31,184,0,0,0,0,31,240,0,0,0,0,63,224,0,0,0,0,63,128,0,0,0,0,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};
void setup() {
// Initialize display
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_I2C_ADDR)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
display.clearDisplay();
// Play animation one time
playAnimationOnce();
Serial.begin(9600);
Serial.println(" ## Saimon Says games by Rahmat F.Z ## ");
rahmat();
displayGameStartMessage();
saimontxt();
display.clearDisplay();
Serial.println(" ## Selamat bermain ## ");
plyrbt();
randomSeed(analogRead(0));
generateNextKey();
setupGame();
setupSimon();
}
void displayGameStartMessage() {
display.clearDisplay();
display.setCursor(0, 10);
display.print("Welcome to Simon Game");
display.setCursor(0, 20);
display.print("Press any key to start");
display.display();
}
void displayscore() {
display.clearDisplay();
display.setCursor(0, 10);
display.print("Score: ");
display.print(score);
display.display();
}
void displayWrongMessage() {
display.clearDisplay();
display.setCursor(0, 10);
display.print("Wrong key!");
display.setCursor(0, 20);
display.print("Game Over");
display.display();
isPlaying = false;
}
void generateNextKey() {
int randIndex = random(0, ROWS * COLS);
expectedKey = keys[randIndex / COLS][randIndex % COLS];
Serial.print("Next key: ");
Serial.println(expectedKey);
}
void checkKeyPressed(char key) {
if (key == expectedKey) {
score++;
displayscore();
generateNextKey();
} else {
displayWrongMessage();
}
}
void saimontxt(){
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.clearDisplay();
display.setCursor(8, (SCREEN_HEIGHT - 16) / 2);
display.print(F("SaimonSays"));
display.display();
delay(3000);
}
void rahmat() {
// After animation ends, display static logo or message
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 20);
// Animasi masuk dari bawah
for (int16_t y = SCREEN_HEIGHT; y >= (SCREEN_HEIGHT - 16) / 2; y -= 2) {
display.clearDisplay();
display.setCursor((SCREEN_WIDTH - 12 * 6) / 2, y); // Menghitung posisi tengah layar
display.print(F("Rahmat"));
display.display();
delay(10); // Delay untuk memperlambat animasi
}
delay(2000); // Tahan teks di tengah selama 2 detik
// Animasi keluar turun
for (int16_t y = (SCREEN_HEIGHT - 16) / 2; y >= -16; y -= 2) {
display.clearDisplay();
display.setCursor((SCREEN_WIDTH - 12 * 6) / 2, y);
display.print(F("Rahmat"));
display.display();
delay(10);
}
}
void plyrbt() {
// Display animation in the center
display.clearDisplay();
// Set text or graphic in the center for plyrbt
display.setTextSize(2); // Set text size
display.setTextColor(SSD1306_WHITE); // Set text color
display.setCursor((SCREEN_WIDTH - 12 * 6) / 2, (SCREEN_HEIGHT - 16) / 2); // Centering text
display.display(); // Refresh display
delay(4000);
center_eyes();
sleep();
delay(2000);
wakeup();
delay(500);
blink();
delay(4000);
}
void playAnimationOnce() {
for (int i = 0; i < FRAME_COUNT; i++) {
display.clearDisplay();
display.drawBitmap(
(SCREEN_WIDTH - FRAME_WIDTH) / 2, // Centering the animation horizontally
(SCREEN_HEIGHT - FRAME_HEIGHT) / 2, // Centering the animation vertically
frames[i], FRAME_WIDTH, FRAME_HEIGHT, 1);
display.display();
delay(FRAME_DELAY);
}
}
void govertxt(){
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.clearDisplay();
display.setCursor(16, (SCREEN_HEIGHT - 16) / 2);
display.print(F("GAME OVER"));
display.display();
setOvertxt(false);
}
void win(){
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.clearDisplay();
display.setCursor(19, (SCREEN_HEIGHT - 16) / 2);
display.print(F("WINNER!!"));
display.display();
setwin(false);
}
void pemilihanlvl() {
if (key) {
Serial.println(key); // Menampilkan tombol yang ditekan
// Memperbarui level dan panjang permainan berdasarkan tombol yang ditekan
if (key >= '1' && key <= '9') {
level = key - '0'; // Mengkonversi karakter ke integer (1-9)
switch (level) {
case 1: MAX_GAME_LENGTH = 10; break;
case 2: MAX_GAME_LENGTH = 15; break;
case 3: MAX_GAME_LENGTH = 20; break;
case 4: MAX_GAME_LENGTH = 25; break;
case 5: MAX_GAME_LENGTH = 30; break;
case 6: MAX_GAME_LENGTH = 35; break;
case 7: MAX_GAME_LENGTH = 40; break;
case 8: MAX_GAME_LENGTH = 45; break;
case 9: MAX_GAME_LENGTH = 50; break;
}
Serial.print("Level diatur ke: ");
Serial.print(level);
Serial.print(", Panjang permainan diatur ke: ");
Serial.println(MAX_GAME_LENGTH);
} else if (key == '0') {
MAX_GAME_LENGTH = 5; // Mengatur ulang panjang permainan ke default
Serial.println("Panjang permainan diatur ke default: 5");
} else if (key == 'A') {
if (level == 0) {
Serial.println("Level tidak ada. Max level hanya 9.");
} else {
Serial.print("Memulai permainan di level: ");
Serial.print(level);
Serial.print(", dengan panjang permainan: ");
Serial.println(MAX_GAME_LENGTH);
// Tambahkan logika untuk memulai permainan di sini
}
}
}
}
void loop() {
char key = keypad.getKey(); // Mendapatkan tombol yang ditekan
robot();
loopSimon();
// Kondisi untuk menampilkan game over text
if (getOvertxt() == true) {
govertxt();
delay(3000);
}
// Kondisi untuk menampilkan pesan kemenangan
if (getwin() == true) {
win();
delay(3000);
}
// Cek apakah game masih berjalan
if (isPlaying) {
pemilihanlvl();
}
}
void cleanupGame();
void cleanup() {
cleanupGame(); // Panggil fungsi cleanup untuk membebaskan memori
}