void setup() {
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(9, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
Serial.begin(9600);
Serial.println("zadaj cislo");
}
void bufferclear() {
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(9, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
delay(2);
while(Serial.available()){
Serial.read();
}
}
void loop() {
int cislo = Serial.parseInt();
while(Serial.available()==0);
if (cislo==1){
digitalWrite(4, LOW);
digitalWrite(5, LOW);
}
else if (cislo==2){
digitalWrite(4, LOW);
digitalWrite(3, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(9, LOW);
}
else if (cislo==3){
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(3, LOW);
digitalWrite(9, LOW);
digitalWrite(6, LOW);
}
else if (cislo==4){
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
}
else if (cislo==5){
digitalWrite(3, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
else if (cislo==6){
digitalWrite(3, LOW);
digitalWrite(9, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
}
else if (cislo==7){
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(3, LOW);
}
else if (cislo==8){
digitalWrite(3, LOW);
digitalWrite(9, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(4, LOW);
}
else if (cislo==9){
digitalWrite(3, LOW);
digitalWrite(9, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(8, LOW);
digitalWrite(4, LOW);
}
else {
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(9, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
}
}