#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 7, 6, 5, 4);
bool testRIGHT = true;
bool testLEFT = true;
bool testUP = true;
bool testDOWN = true;
bool testRESET = true;
int cislo = -1;
int cislo2 = 0;
uint8_t stickman[8]={
0b01110,
0b01110,
0b00100,
0b01110,
0b10101,
0b00100,
0b01010,
0b10001,
};
void setup() {
pinMode(A5, INPUT_PULLUP);
pinMode(A4, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
lcd.createChar(1, stickman);
lcd.begin(20, 4);
lcd.print("\x01");
}
void loop() {
if (digitalRead(A5) == LOW && testRIGHT == true)
{
testRIGHT = false;
if (cislo < 19)
{
lcd.clear();
cislo ++;
lcd.setCursor(cislo,cislo2);
lcd.print("\x01");
}
}
else if (digitalRead(A5) == HIGH && testRIGHT == false)
{
testRIGHT = true;
}
if (digitalRead(A4) == LOW && testLEFT == true)
{
testLEFT = false;
if (cislo > -1)
{
lcd.clear();
cislo --;
lcd.setCursor(cislo,cislo2);
lcd.print("\x01");
}
}
else if (digitalRead(A4) == HIGH && testLEFT == false)
{
testLEFT = true;
}
if (digitalRead(A3) == LOW && testUP == true)
{
testUP = false;
if (cislo2 > 0)
{
lcd.clear();
cislo2 --;
lcd.setCursor(cislo,cislo2);
lcd.print("\x01");
}
}
else if (digitalRead(A3) == HIGH && testUP == false)
{
testUP = true;
}
if (digitalRead(A2) == LOW && testDOWN == true)
{
testDOWN = false;
if (cislo2 < 4)
{
lcd.clear();
cislo2 ++;
lcd.setCursor(cislo,cislo2);
lcd.print("\x01");
}
}
else if (digitalRead(A2) == HIGH && testDOWN == false)
{
testDOWN = true;
}
}