#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
const byte buzzerpin = 6;
const byte startbuttonpin = 8;
const byte selectbuttonpin = 7;
unsigned long comeca = millis();
byte estado = 0;
byte estadocron = 0;
byte option = 2;
int timer = 10;
int megasena[6];
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
//Image figdados is 100x60
const unsigned char figdados [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0xe0, 0xff, 0xfe, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0xe0, 0x7f, 0xfe, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xe0, 0x7f, 0xff, 0x84, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xf0, 0xff, 0xfc, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0xf0, 0x7f, 0xff, 0xf8, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0xf0, 0x7f, 0xff, 0xfc, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0x7f, 0xff,
0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0xf8, 0x7f, 0xff, 0xff, 0x8f, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x30, 0x7f, 0xff, 0xff, 0xf8, 0x7f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x30, 0x3f, 0xff, 0xe3, 0xf0, 0x1f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3f, 0xff,
0xc3, 0xf8, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0xff, 0xff, 0xc0, 0xfc, 0x0f,
0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xc0, 0xff, 0x3f, 0xf8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xfb, 0xc0, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0f, 0xff, 0xe3, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x87, 0xc0, 0x00, 0x00, 0x07, 0xff,
0xe0, 0x7f, 0xff, 0xff, 0xfc, 0x03, 0xff, 0x00, 0xf0, 0x00, 0x00, 0x07, 0xff, 0xe0, 0x7f, 0xff,
0xff, 0xfe, 0x01, 0xff, 0xe0, 0xf8, 0x00, 0x00, 0x03, 0xff, 0xe0, 0x7f, 0xc0, 0xff, 0xff, 0xef,
0xff, 0xfc, 0x3e, 0x00, 0x00, 0x03, 0xf0, 0xf8, 0xff, 0x00, 0xff, 0xff, 0xe0, 0x7f, 0xf8, 0x03,
0x80, 0x00, 0x01, 0xf0, 0xff, 0xff, 0x01, 0xff, 0x9f, 0xc0, 0x0f, 0xfe, 0x03, 0xc0, 0x00, 0x00,
0xe0, 0x7f, 0xff, 0x03, 0xff, 0x9f, 0xe0, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0xf0, 0x7f, 0xff,
0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xe0, 0x38, 0x00, 0x00, 0x70, 0x7f, 0xff, 0xff, 0xfc, 0x4f,
0xff, 0x03, 0xff, 0xe0, 0x06, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xf8, 0xcf, 0xfc, 0x00, 0x7f,
0xf8, 0x03, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xfe, 0x00, 0x3f, 0xff, 0x9f, 0x80,
0x00, 0x1f, 0xff, 0xff, 0x0f, 0x80, 0xff, 0xff, 0x80, 0x7f, 0xff, 0xff, 0xc0, 0x00, 0x0f, 0xff,
0xf8, 0x06, 0x00, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x03, 0xff, 0xf8, 0x08, 0x00,
0xfe, 0x3f, 0xff, 0xff, 0xff, 0xc0, 0xc0, 0x00, 0x00, 0x1f, 0xf8, 0x60, 0x00, 0xee, 0x1f, 0xff,
0xff, 0xff, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0xe6, 0x1f, 0xe0, 0xff, 0xff, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe3, 0x1f, 0x80, 0x7f, 0xfe, 0x00, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xe3, 0x1f, 0x00, 0x7f, 0xfe, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x61, 0x9e, 0x00, 0x7f, 0xfe, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x9e,
0x00, 0x7f, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0xfe, 0x00, 0xff, 0xff,
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1f, 0xff, 0x01, 0xff, 0xff, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x9f, 0xff, 0xdf, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7d, 0xff, 0xff, 0xff,
0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xff, 0xff, 0xff, 0xf8, 0x30, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x18, 0x7f, 0xff, 0xff, 0xe0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0c, 0x7f, 0xff, 0xff, 0xe0, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x7c, 0x1f,
0xff, 0xc0, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x70, 0x0f, 0xff, 0xc0, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x0f, 0xff, 0xe1, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x0f, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x1f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0,
0x7f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// image figcron, 100x60px
const unsigned char figcron [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xc0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xe0, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x70, 0x00, 0xe0, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe0, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x1f, 0xff,
0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xb0, 0x7f, 0xff, 0xc1, 0xb8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3b, 0xff, 0xff, 0xf3, 0x9c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0e, 0x23, 0xfc, 0x07, 0xf8, 0x8e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0c, 0x0f, 0xc3, 0xf8, 0x7e, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x3f,
0xbf, 0x9f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x7f, 0xbf, 0xcf, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0xff, 0xbf, 0xf3, 0xc0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0xff, 0xbf, 0xf9, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe7, 0xff, 0xbf, 0xfc, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xec,
0xff, 0xbf, 0xe6, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xde, 0x7f, 0xbf, 0xcf,
0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x9f, 0x7f, 0xbf, 0x9f, 0x78, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xbf, 0xff, 0xbf, 0xff, 0xbc, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0x3f, 0xff, 0xbf, 0xff, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0x3f, 0xff, 0xbf, 0xff, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x7f, 0xff, 0xbf,
0xff, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x7f, 0xff, 0xbf, 0xff, 0xde, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0xff, 0xff, 0xbf, 0xff, 0xee, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0e, 0xff, 0xff, 0xbf, 0xff, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0e, 0xff, 0xff, 0xbf, 0xff, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0xc3, 0xff,
0xbf, 0xf8, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0xff, 0xff, 0xff, 0xff, 0xee,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0xff, 0xff, 0xff, 0xff, 0xee, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0f, 0x7f, 0xff, 0xff, 0xff, 0xde, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x7f, 0xff, 0xff, 0xff, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3f,
0xff, 0xff, 0xff, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3f, 0xff, 0xff, 0xff,
0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xbf, 0xff, 0xff, 0xff, 0xbc, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x9f, 0x7f, 0xff, 0x9f, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xde, 0x7f, 0xff, 0xcf, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xcc, 0xff, 0xff, 0xe6, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe5, 0xff, 0xbf,
0xf4, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf7, 0xff, 0xbf, 0xf9, 0xe0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xff, 0xbf, 0xf3, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7c, 0xff, 0xbf, 0xe7, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3e, 0x3f, 0xbf, 0x8f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x87,
0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf0, 0x01, 0xfc, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x1f, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void setup() {
Serial.begin(115200);
pinMode(startbuttonpin, INPUT_PULLUP);
pinMode(selectbuttonpin, INPUT_PULLUP);
pinMode(buzzerpin, OUTPUT);
randomSeed(analogRead(0));
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("Display OLED desconectado"));
for(;;);
}
}
void loop() {
switch (estado) {
case 0:
desenhamenu();
estado = 1;
break;
case 1:
cuidamenu();
break;
case 2:
display.clearDisplay();
display.display();
display.drawBitmap(14, 0, figcron, 100, 60, WHITE);
display.display();
delay(2000);
display.clearDisplay();
mostra(timer);
display.display();
estado = 4;
break;
case 3:
display.clearDisplay();
display.display();
display.drawBitmap(14, 0, figdados, 100, 60, WHITE);
display.display();
delay(2000);
mostradado(1);
estado = 5;
break;
case 4:
if (estadocron==0 && digitalRead(selectbuttonpin)==LOW){
timer += 5;
if (timer > 120) {timer = 10;}
mostra(timer);
cronometro(timer);
delay(200);
}
if (estadocron==0 && digitalRead(startbuttonpin)==LOW){
delay(100);
estadocron = 1;
}
if (estadocron == 1) {
cronometro(timer);
if (digitalRead(startbuttonpin)==LOW) {
estadocron = 0;
}
}
break;
case 5:
if (digitalRead(startbuttonpin)==LOW){
sorteia();
tone(buzzerpin,700,50);
}
break;
case 6:
if (digitalRead(startbuttonpin) == LOW) {
mega();
}
break;
}
}
void desenhamenu() {
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 15);
display.print("Cronom.");
display.drawChar(100, 15, 0x1B, 1, 0, 2);
display.println();
display.print("Dados");
display.println();
display.print("MegaSena");
display.display();
}
void cuidamenu() {
if (option == 2 && digitalRead(selectbuttonpin) == LOW) {
option = 3;
display.fillRect(99, 15, 12, 12, BLACK);
display.drawChar(100, 30, 0x1B, 1, 0, 2);
display.display();
delay(200);
}
if (option == 3 && digitalRead(selectbuttonpin) == LOW) {
option = 6;
display.fillRect(99, 30, 12, 12, BLACK);
display.drawChar(100, 50, 0x1B, 1, 0, 2);
display.display();
delay(200);
}
if (option == 6 && digitalRead(selectbuttonpin) == LOW) {
option = 2;
display.fillRect(99, 50, 12, 12, BLACK);
display.drawChar(100, 15, 0x1B, 1, 0, 2);
display.display();
delay(200);
}
if (digitalRead(startbuttonpin) == LOW) {
estado = option;
}
}
void cronometro(int segs) {
static int tempo = segs+1;
if (estadocron == 1){
if (millis()-comeca>=1000) {
tempo--;
mostra(tempo);
comeca=millis();
if (tempo <=5 && tempo!=0) {tone(buzzerpin,500,20);}
}
if (tempo==0) {
tone(buzzerpin,700,100);
delay(100);
tempo = segs+1;
estadocron = 0;
}
}
else tempo = segs+1;
}
void mostra(int num){
display.clearDisplay();
display.setTextSize(4);
if (num >=100) {
display.setCursor(30, 15);
}
else if (num < 10) {
display.setCursor(55, 15);
}
else {
display.setCursor(45, 15);
}
display.print(num);
display.display();
}
void sorteia() {
for (int i=1; i<=15; i++) {
int randNumber = random(1,7);
mostradado(randNumber);
delay(sq(i));
}
}
void mostradado(int num) {
display.clearDisplay();
display.display();
display.fillRoundRect(34,2,60,60,8,SSD1306_WHITE);
switch (num) {
case 1:
display.fillCircle(64,32,5,SSD1306_BLACK);
break;
case 2:
display.fillCircle(79,17,5,SSD1306_BLACK);
display.fillCircle(49,47,5,SSD1306_BLACK);
break;
case 3:
display.fillCircle(79,17,5,SSD1306_BLACK);
display.fillCircle(64,32,5,SSD1306_BLACK);
display.fillCircle(49,47,5,SSD1306_BLACK);
break;
case 4:
display.fillCircle(49,17,5,SSD1306_BLACK);
display.fillCircle(79,17,5,SSD1306_BLACK);
display.fillCircle(49,47,5,SSD1306_BLACK);
display.fillCircle(79,47,5,SSD1306_BLACK);
break;
case 5:
display.fillCircle(49,17,5,SSD1306_BLACK);
display.fillCircle(79,17,5,SSD1306_BLACK);
display.fillCircle(64,32,5,SSD1306_BLACK);
display.fillCircle(49,47,5,SSD1306_BLACK);
display.fillCircle(79,47,5,SSD1306_BLACK);
break;
case 6:
display.fillCircle(49,17,5,SSD1306_BLACK);
display.fillCircle(79,17,5,SSD1306_BLACK);
display.fillCircle(49,32,5,SSD1306_BLACK);
display.fillCircle(79,32,5,SSD1306_BLACK);
display.fillCircle(49,47,5,SSD1306_BLACK);
display.fillCircle(79,47,5,SSD1306_BLACK);
break;
}
display.display();
}
void mega() {
for (int i = 0; i <= 5; i++) {
megasena[i] = random(1, 61);
//verifica se tem algum número repetido e sorteia novamente
if (i>0) {
for (int j = 0; j < i; j++){
if (megasena[i] == megasena[j]){
i=i-1;
}
}
}
}
ordena();
mostramega();
}
void ordena() {
int i, j, flag = 1;
int temp;
for (i = 1; (i <= 5) && flag; i++)
{
flag = 0;
for (j = 0; j < 5; j++)
{
if (megasena[j + 1] < megasena[j])
{
temp = megasena[j];
megasena[j] = megasena[j + 1];
megasena[j + 1] = temp;
flag = 1;
}
}
}
}
void mostramega(){
display.clearDisplay();
display.setCursor(0, 16);
for (int i = 0; i <= 5; i++) {
display.print(megasena[i]);
if (i<5) {display.print("-");}
if (i==2) {
display.println();
display.println();
}
}
display.display();
delay(500);
}