Gissa/plocka AttinyCard (2 / 3 steg)
Steg 2: programvara
Skiss uppmanas du att ta ett kort förmodligen från en kortlek med 52 kort. Tryck på knappen Stoppa i slumpvis ordning. Visar nummer slumpmässigt plockas ur 52 på första raden. Kort representeras på andra raden.
#include < LiquidCrystal595.h >
LiquidCrystal595 lcd(0,1,2);
int val; slumpmässigt kort värde
CONST int knappen = 4; knappen pin
int buttonState = 0;
void setup() {
LCD.BEGIN(16,2);
LCD.Clear();
lcd.setCursor(0,0);
LCD.Print ("Välj A kort");
LCD.Print ("CUT");
lcd.setCursor(0,1);
LCD.Print ("kom ihåg IT");
LCD.Print ("däck");
pinMode (knapp, indata);
Delay(5000);
}
void loop() {
Val = random(1,52);
buttonState = digitalRead(button);
om (buttonState == hög) {
LCD.Clear();
lcd.setCursor(6,0);
LCD.Print(val);
Växla (val) {
fall 1:lcd.setCursor(4,1);
LCD.Print ("ACE S");
bryta;
fall 2:lcd.setCursor(4,1);
LCD.Print ("2 S").
bryta;
fall 3:lcd.setCursor(4,1);
LCD.Print ("3 S").
bryta;
fall 4:lcd.setCursor(4,1);
LCD.Print ("4 S").
bryta;
fall 5:lcd.setCursor(4,1);
LCD.Print ("5 S").
bryta;
fall 6:lcd.setCursor(4,1);
LCD.Print ("6 S").
bryta;
fall 7:lcd.setCursor(4,1);
LCD.Print ("7 S").
bryta;
fall 8:lcd.setCursor(4,1);
LCD.Print ("8 S").
bryta;
fall 9:lcd.setCursor(4,1);
LCD.Print ("9 S").
bryta;
fall 10:lcd.setCursor(4,1);
LCD.Print ("10 S").
bryta;
fall 11:lcd.setCursor(4,1);
LCD.Print ("JACK S");
bryta;
fall 12:lcd.setCursor(4,1);
LCD.Print ("QUEEN S");
bryta;
fall 13:lcd.setCursor(4,1);
LCD.Print ("kung S");
bryta;
fall 14:lcd.setCursor(4,1);
LCD.Print ("ACE D");
bryta;
fall 15:lcd.setCursor(4,1);
LCD.Print ("2 D").
bryta;
fall 16:lcd.setCursor(4,1);
LCD.Print ("3 D").
bryta;
fall 17:lcd.setCursor(4,1);
LCD.Print ("4 D").
bryta;
fall 18:lcd.setCursor(4,1);
LCD.Print ("5 D").
bryta;
fall 19:lcd.setCursor(4,1);
LCD.Print ("6 D").
bryta;
fall 20:lcd.setCursor(4,1);
LCD.Print ("7 D").
bryta;
fall 21:lcd.setCursor(4,1);
LCD.Print ("8 D").
bryta;
fall 22:lcd.setCursor(4,1);
LCD.Print ("9 D").
bryta;
fall 23:lcd.setCursor(4,1);
LCD.Print ("10 D").
bryta;
fall 24:lcd.setCursor(4,1);
LCD.Print ("JACK D");
bryta;
fall 25:lcd.setCursor(4,1);
LCD.Print ("QUEEN D");
bryta;
fall 26:lcd.setCursor(4,1);
LCD.Print ("kung D");
bryta;
fall 27:lcd.setCursor(4,1);
LCD.Print ("ACE C");
bryta;
fall 28:lcd.setCursor(4,1);
LCD.Print ("2 C").
bryta;
fall 29:lcd.setCursor(4,1);
LCD.Print ("3 CLUB");
bryta;
fall 30:lcd.setCursor(4,1);
LCD.Print ("4 C").
bryta;
fall 31:lcd.setCursor(4,1);
LCD.Print ("5 C").
bryta;
fall 32:lcd.setCursor(4,1);
LCD.Print ("6 C").
bryta;
fall 33:lcd.setCursor(4,1);
LCD.Print ("7 C").
bryta;
fall 34:lcd.setCursor(4,1);
LCD.Print ("8 C").
bryta;
fall 35:lcd.setCursor(4,1);
LCD.Print ("9 C").
bryta;
fall 36:lcd.setCursor(4,1);
LCD.Print ("10 C").
bryta;
fall 37:lcd.setCursor(4,1);
LCD.Print ("JACK C");
bryta;
fall 38:lcd.setCursor(4,1);
LCD.Print ("QUEN C");
bryta;
fall 39:lcd.setCursor(4,1);
LCD.Print ("kung C").
bryta;
fall 40:lcd.setCursor(4,1);
LCD.Print ("ACE H");
bryta;
fall 41:lcd.setCursor(4,1);
LCD.Print ("2 H").
bryta;
fall 42:lcd.setCursor(4,1);
LCD.Print ("3 H").
bryta;
fall 43:lcd.setCursor(4,1);
LCD.Print ("4 H").
bryta;
fall 44:lcd.setCursor(4,1);
LCD.Print ("5 H").
bryta;
fall 45:lcd.setCursor(4,1);
LCD.Print ("6 H").
bryta;
fall 46:lcd.setCursor(4,1);
LCD.Print ("7 H").
bryta;
fall 47:lcd.setCursor(4,1);
LCD.Print ("8 H").
bryta;
fall 48:lcd.setCursor(4,1);
LCD.Print ("9 H").
bryta;
fall 49:lcd.setCursor(4,1);
LCD.Print ("10 H").
bryta;
fall 50:lcd.setCursor(4,1);
LCD.Print ("JACK H");
bryta;
fall 51:lcd.setCursor(4,1);
LCD.Print ("drottning H");
bryta;
fall 52:lcd.setCursor(4,1);
LCD.Print ("kung H");
bryta;
}
}
}