#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int st = 0;
int prstPin = 2;
int odstPin = 3;
int nullPin = 4;
int rndPin = 5;
int randNum;
String a = "Stevec: ";
void setup() {
randomSeed(analogRead(A0));
pinMode(prstPin, INPUT_PULLUP);
pinMode(odstPin, INPUT_PULLUP);
pinMode(nullPin, INPUT_PULLUP);
pinMode(rndPin, INPUT_PULLUP);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(a);
}
void loop() {
lcd.setCursor(8, 0);
lcd.print(st);
int buttonState;
buttonState = digitalRead(prstPin);
switch (buttonState) {
case LOW:
st++;
break;
}
buttonState = digitalRead(odstPin);
switch (buttonState) {
case LOW:
st--;
break;
}
buttonState = digitalRead(nullPin);
switch (buttonState) {
case LOW:
st = 000;
break;
}
buttonState = digitalRead(rndPin);
switch (buttonState) {
case LOW:
randNum = random(1, 10);
st = st + randNum;
break;
}
delay(200);
}