#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27
#define LCD_COLUMNS 20
#define LCD_ROWS 4
int motion = 8;
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_ROWS);
void setup() {
// put your setup code here, to run once:
lcd.begin(20, 4);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
RandomX();
delay(2000);
}
void RandomX() {
int motionValue = digitalRead(motion);
if(motionValue == 1){
lcd.clear();
int pocetX = random(1,40);
for (int i = 0; i < pocetX; i++) {
int x = random(20);
//Serial.println(x);
int y = random(4);
//Serial.println(y);
lcd.setCursor(x, y);
lcd.print("X");
}
Serial.println(pocetX);
}
}