#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
bool szamok [10] [7] =
{
{HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,LOW}, //0
{LOW,HIGH,HIGH,LOW,LOW,LOW,LOW}, //1
{HIGH,HIGH,LOW,HIGH,HIGH,LOW,HIGH}, //2
{HIGH,HIGH,HIGH,HIGH,LOW,LOW,HIGH}, //3
{LOW,HIGH,HIGH,LOW,LOW,HIGH,HIGH}, //4
{HIGH,LOW,HIGH,HIGH,LOW,HIGH,HIGH}, //5
{HIGH,LOW,HIGH,HIGH,HIGH,HIGH,HIGH}, //6
{HIGH,HIGH,HIGH,LOW,LOW,HIGH,LOW}, //7
{HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH}, //8
{HIGH,HIGH,HIGH,HIGH,LOW,HIGH,HIGH} //9
};
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
Serial.begin(9600);
//initialize lcd screen
lcd.init();
// turn on the backlight
lcd.backlight();
lcd.setCursor(5, 0);
// tell the screen to write “hello, from” on the top row
lcd.print("Hello");
delay(500);
lcd.clear();
}
int korok= 0;
int akadaly= 0;
int hely2= 0;
int szam;
int segment =3;
int ido;
void jelez ()
{
lcd.setCursor(hely2,0);
lcd.print("HHH");
delay(5);
lcd.clear();
}
void loop()
{
//Serial.println(analogRead(3));
int poti = analogRead(3);
int hely = poti /64;
//Serial.println(akadaly);
//Serial.println(hely2);
lcd.clear();
lcd.setCursor(hely,1);
lcd.print("o");
if (akadaly > 2)
{
if (korok == 10)
hely2++;
if (hely2>13)
hely2=13;
jelez();
}
else if (akadaly < 2)
{
if (korok == 10)
hely2--;
if (hely2 < 0)
hely2=0;
jelez();
}
if (korok == 10)
{
if (hely2 <= hely && hely2+2 >= hely)
{
ido++;
if (ido == 5)
segment--;
else if (ido == 10)
segment--;
else if (ido == 15)
{
segment = 0;
ido = 0;
lcd.clear();
lcd.setCursor(5, 0);
lcd.print("nyertel");
delay(500);
lcd.clear();
}
delay(5);
}
else
{
segment = 3;
ido = 0;
}
akadaly = random(5);
korok = 0;
}
digitalWrite(2, szamok [segment] [0]);
digitalWrite(3, szamok [segment] [1]);
digitalWrite(4, szamok [segment] [2]);
digitalWrite(5, szamok [segment] [3]);
digitalWrite(6, szamok [segment] [4]);
digitalWrite(7, szamok [segment] [5]);
digitalWrite(8, szamok [segment] [6]);
delay(5);
korok++;
}