int pole[10][10]{
{HIGH,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,},
{HIGH,HIGH,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,},
{HIGH,HIGH,HIGH,LOW,LOW,LOW,LOW,LOW,LOW,LOW,},
{HIGH,HIGH,HIGH,HIGH,LOW,LOW,LOW,LOW,LOW,LOW,},
{HIGH,HIGH,HIGH,HIGH,HIGH,LOW,LOW,LOW,LOW,LOW,},
{HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,LOW,LOW,LOW,LOW,},
{HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,LOW,LOW,LOW,},
{HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,LOW,LOW,},
{HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,LOW,},
{HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH},
};
void setup() {
for(int i=2;i<12;i++)
pinMode(i, OUTPUT);
Serial.begin(9600);
Serial.println("Zadanie: ");
Serial.println("Napíš percento od 10-100");
}
void per(int c){
digitalWrite(2,pole[c][0]);
digitalWrite(3,pole[c][1]);
digitalWrite(4,pole[c][2]);
digitalWrite(5,pole[c][3]);
digitalWrite(6,pole[c][4]);
digitalWrite(7,pole[c][5]);
digitalWrite(8,pole[c][6]);
digitalWrite(9,pole[c][7]);
digitalWrite(10,pole[c][8]);
digitalWrite(11,pole[c][9]);
}
void loop() {
while( ! Serial.available() );
long cislo = Serial.parseInt();
bufferCleaner();
if(cislo==10)
{
per(0);
}
else if(cislo==20)
{
per(1);
}
else if(cislo==30)
{
per(2);
}
else if(cislo==40)
{
per(3);
}
else if(cislo==50)
{
per(4);
}
else if(cislo==60)
{
per(5);
}
else if(cislo==70)
{
per(6);
}
else if(cislo==80)
{
per(7);
}
else if(cislo==90)
{
per(8);
}
else if(cislo==100)
{
per(9);
}
else{
Serial.println("error");
}
}
void bufferCleaner()
{
delay(1);
while(Serial.available())
Serial.read();
}