Decisamente il repo più importante sul Git del LILiK. requirements: -Arduino compatible board at 5V logic level -16x2 LCD -breadboard and some jumpers Functionality: self-explainatory
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
5.3 KiB

1 year ago
  1. #include <LiquidCrystal.h>
  2. int D = 0; // Pointer Divinità in array
  3. int I = 0; // Pointer Insulto in array
  4. int agender = 0; // Variable to select non-gendered insults
  5. int Gender = 1; // Variable to store gender
  6. int ratio = 1; // Ratio between gendered/non-gendered insults
  7. unsigned int strlength = 1; // Variable to store Length of individual insult
  8. String Riga1 = "A"; // String to print for Divinità
  9. String Riga2 = "B"; // String to print for insult
  10. char *DivinitaF[] = { "Madonna", "Eva", "Maria",
  11. "Maria Benedetta", "MadonnaImpestata", "Madre Teresa",
  12. "Porcamadonna", "Maria Maledetta",
  13. };
  14. char *DivinitaM[] = { "Dio", "Giuseppe", "San Giuseppe",
  15. "Gesu'", "Cristo", "Papa Francesco",
  16. "Papa Nazingher", "Gesu' Cristo", "DioBestia",
  17. "Iddio", "Padre Eterno", "Porcoddio",
  18. "Dio Serpente", "Giuda", "Porco il Clero",
  19. "Adamo",
  20. };
  21. char *InsultiFM[] = {"Sparata", "Arrestata", "Smerdata",
  22. "Porca", "Stronza", "Galeotta",
  23. "Merdosa", "Lurida", "Mafiosa",
  24. "Ladra", "Carbonizzata", "Sciolta",
  25. "Sudicia", "Assassina", "Sotterrata",
  26. "Scoppiata", "Ingessata", "Pietrificata",
  27. "Diavola", "Lupa", "Incazzata",
  28. "Inviperita", "Marcia", "Infangata"
  29. "Scatenata", "Piena", "Avvelenata",
  30. "Sbronza", "Radioattiva", "Pisana",
  31. "Cogliona", "Velenosa", "Ammazzata",
  32. "Fascista Appesa", "Lebbrosa", "Drogata",
  33. "Smutandata", "Catafratta", "Pisana",
  34. "Infangata", "Asfaltata", "Scivolata",
  35. "Inchiodata", "Decaffeinata", "Slurdata",
  36. "Viscida", "Gonfia", "Nana",
  37. };
  38. char *InsultiA[] = { "Cane", "A Pedali", "C'ho Fame!",
  39. "Chepppalle!", "In croce", "con la diarrea",
  40. "Terrorista", "Camorrista", "Infame",
  41. "In fiamme", "Fascista", "Boia",
  42. "Frittata", "Biscia", "in Carriola",
  43. "Missile", "Serpente", "Maiale",
  44. "Autostoppista", "Lontra", "Merda",
  45. "Verme", "Infame", "Agghiacciante",
  46. "Cinghiale", "Camorrista", "Atomo",
  47. "Bengala",
  48. };
  49. int DFSize = sizeof(DivinitaF) / sizeof(DivinitaF[0]); // Automatically calculate size of arrays based on string lenght
  50. int DMSize = sizeof(DivinitaM) / sizeof(DivinitaM[0]);
  51. int IFMSize = sizeof(InsultiFM) / sizeof(InsultiFM[0]);
  52. int IASize = sizeof(InsultiA) / sizeof(InsultiA[0]);
  53. // LCD pins <--> Arduino pins
  54. const int RS = 11, EN = 12, D4 = 2, D5 = 3, D6 = 4, D7 = 5;
  55. LiquidCrystal lcd(RS, EN, D4, D5, D6, D7);
  56. void setup()
  57. {
  58. ratio = 100*IFMSize/(IFMSize + IASize); //(The smallest IASize, the slimmenst the chance to pick from corresponding array)
  59. // Setup LCD and print boot messages once
  60. lcd.begin(16, 2); // set up number of columns and rows
  61. lcd.setCursor(0, 0); // move cursor to (0, 0)
  62. lcd.print("GeneratoreRandom");
  63. lcd.setCursor(0, 1); // move cursor to (0, 1)
  64. lcd.print("Di Bestemmie 1.1");
  65. delay(5000);
  66. lcd.clear(); // Clear LCD before re-draw
  67. lcd.setCursor(0, 0); // move cursor to (0, 0)
  68. lcd.print("by AulaStud");
  69. lcd.setCursor(0, 1); // move cursor to (0, 1)
  70. lcd.print("2022");
  71. delay(2000);
  72. }
  73. void loop()
  74. {
  75. lcd.clear(); // Clear LCD at every cycle
  76. Gender = random(1, 3); // Randomly pick F/M as 1 or 2. generate from 1 to n+1 where n is the desired maximum
  77. if (Gender == 1) { // Check what group has been picked (F/M)
  78. D = random(1, DFSize); // Randomply pick string in array; from 1 to n+1 where n is the desired maximum
  79. Riga1 = DivinitaF[D]; // Fill lines that will be printed to LCD
  80. }
  81. else if (Gender == 2) { // Check what group has been picked (F/M)
  82. D = random(1, DMSize);
  83. Riga1 = DivinitaM[D]; // Fill lines that will be printed to LCD
  84. }
  85. agender = random(1, 101);
  86. if (agender < ratio) { // Extra option to pick Non-gendered insults
  87. I = random(1, IASize);
  88. Riga2 = InsultiA[I]; // Fill lines that will be printed to LCD
  89. }
  90. else { // else pick insult and change gender
  91. I = random(1, IFMSize);
  92. Riga2 = InsultiFM[I]; // Fill lines that will be printed to LCD
  93. }
  94. lcd.setCursor(0, 0); // move cursor to (0, 0)
  95. lcd.print(Riga1); // Print Line1
  96. lcd.setCursor(0, 1); // move cursor to (0, 1)
  97. lcd.print(Riga2); // Print Line2
  98. if (Gender == 2 && agender >= ratio) {
  99. strlength = Riga2.length() - 1; // get length of current insult string
  100. lcd.setCursor(strlength, 1); // move cursor to end of insult
  101. lcd.print("o"); // print final letter over end of line2 to change F to M
  102. }
  103. delay(5000); // Delay 5s before next cycle
  104. agender = 3; // Reset variable
  105. Riga1 = ""; // Clear strings, or characters will overlap sometimes
  106. Riga2 = "";
  107. }