#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
int cislo = 0;
bool test = true;
int i = 0; // pozicia registra
void setup() {
DDRD |= 0b11111111; // vystup
DDRC |= 0b01111100;// A0 vstup a1 float
lcd.begin(16,2);
//you get input pullup when the bit in the DDRx register is 0
// while the same bit in PORTx is 1.
PORTC |= 1<<0; //pull up
randomSeed(analogRead(A1));
Serial.begin(9600);
}
void loop() {
if((PINC& (1<<0)) == 0 && test == true){
cislo = random(0,10);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(cislo);
Serial.println(cislo);
test = false;
}
for(int i = 2; i <= cislo && i <8 ; i++)
{
PORTD |= 1<<i;
delay(500);
}
PORTD &= 0b0000000;
if((PINC& (1<<0)) != 0 && test == false){
test = true;
}
}