#include <LiquidCrystal.h>
LiquidCrystal lcd = LiquidCrystal(9,8,5,4,3,2);
int position = 0;
int posz = 0;
bool test = true, test2 = true;
bool test3 = true, test4 = true;
void setup() {
Serial.begin(9600);
pinMode(A4, INPUT);
digitalWrite(A4, HIGH);
pinMode(A5, INPUT);
digitalWrite(A5, HIGH);
pinMode(A3, INPUT);
digitalWrite(A3, HIGH);
pinMode(A2, INPUT);
digitalWrite(A2, HIGH);
lcd.begin(16,2);
uint8_t heart[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000,
};
lcd.createChar(3, heart);
lcd.clear();
lcd.print("\x03");
}
void loop() {
if (digitalRead(A5) == LOW && test) {
test = false;
if (position < 15) {
position++;
}
Serial.println(position);
lcd.clear();
lcd.setCursor(position, posz);
lcd.print("\x03");
delay(10);
}
if (digitalRead(A5) == HIGH && !test) {
test = true;
delay(10);
}
if (digitalRead(A4) == LOW && test2) {
test2 = false;
if (position > 0) {
position--;
}
Serial.println(position);
lcd.clear();
lcd.setCursor(position, posz);
lcd.print("\x03");
delay(10);
}
if (digitalRead(A4) == HIGH && !test2) {
test2 = true;
delay(10);
}
if (digitalRead(A3) == LOW && test3) {
test3 = false;
if (posz < 1 ) {
posz++;
}
Serial.println(posz);
lcd.clear();
lcd.setCursor(position, posz);
lcd.print("\x03");
delay(10);
}
if (digitalRead(A3) == HIGH && !test3) {
test3 = true;
delay(10);
}
if (digitalRead(A2) == LOW && test4) {
test4 = false;
if (posz > 0) {
posz--;
}
Serial.println(posz);
lcd.clear();
lcd.setCursor(position, posz);
lcd.print("\x03");
delay(10);
}
if (digitalRead(A2) == HIGH && !test4) {
test4 = true;
delay(10);
}
}