SHARE
TWEET

blabla

a guest Sep 17th, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <avr/pgmspace.h>
  2.  
  3. const String characters1 = "il.:!'|";
  4. const String characters2 = "[] ";
  5. const String characters3 = "Ifj-()º";
  6. const String characters4 = "abcdeghknopqrstuxy1234567890_=";
  7. const String characters5 = "ABCDEFGHJKLMNOPQRSTUVWXYZmvwz+&?#€$";
  8. const String characters7 = "@%/\\";
  9.  
  10.  
  11. const char i[] PROGMEM = "0101111";
  12. const char l[] PROGMEM = "1111111";
  13. const char sc07[] PROGMEM = "0000001"; // .
  14. const char sc08[] PROGMEM = "0010100"; // :
  15. const char sc13[] PROGMEM = "1111101"; // !
  16. const char sc20[] PROGMEM = "1100000"; // '
  17. const char sc24[] PROGMEM = "1111111"; // |
  18.  
  19. const char sc05[] PROGMEM = "11111111000001"; // [
  20. const char sc06[] PROGMEM = "10000011111111"; // ]
  21. const char sc00[] PROGMEM = "00000000000000"; // space
  22.  
  23. const char I[] PROGMEM = "100000111111111000001";
  24. const char f[] PROGMEM = "001111101001000100000";
  25. const char j[] PROGMEM = "000000100000010101110";
  26. const char sc01[] PROGMEM = "000100000010000001000"; // -
  27. const char sc03[] PROGMEM = "001110001000101000001"; // (
  28. const char sc04[] PROGMEM = "100000101000100011100"; // )
  29. const char sc19[] PROGMEM = "110000000000001100000"; // "
  30. const char sc21[] PROGMEM = "010000010100000100000"; // º
  31.  
  32. const char a[] PROGMEM = "0000011001010100101010011111";
  33. const char b[] PROGMEM = "1111111001000100100010001110";
  34. const char c[] PROGMEM = "0001110001000100100010010001";
  35. const char d[] PROGMEM = "0001110001000100100011111111";
  36. const char e[] PROGMEM = "0001110001010100101010001101";
  37. const char g[] PROGMEM = "0001001001010100101010011110";
  38. const char h[] PROGMEM = "0111111000100000010000000111";
  39. const char k[] PROGMEM = "0111111000010000010100000001";
  40. const char n[] PROGMEM = "0001111001000000100000001111";
  41. const char o[] PROGMEM = "0001110001000100100010001110";
  42. const char p[] PROGMEM = "0011111001010000101000001000";
  43. const char q[] PROGMEM = "0001000001010000101000011111";
  44. const char r[] PROGMEM = "0011111000100000100000010000";
  45. const char s[] PROGMEM = "0001001001010100101010010010";
  46. const char t[] PROGMEM = "0010000011111000100010000001";
  47. const char u[] PROGMEM = "0011110000000100000010011110";
  48. const char x[] PROGMEM = "0011011000010000001000011011";
  49. const char y[] PROGMEM = "0011001000010100001010011110";
  50. const char _1[] PROGMEM = "0010000010000111111110000001";
  51. const char _2[] PROGMEM = "0110011100010110010010110001";
  52. const char _3[] PROGMEM = "0100010100000110010010110110";
  53. const char _4[] PROGMEM = "1111100000010000011110000100";
  54. const char _5[] PROGMEM = "1110010101000110100011001110";
  55. const char _6[] PROGMEM = "0111110100100110010010100110";
  56. const char _7[] PROGMEM = "1000000100111110100001100000";
  57. const char _8[] PROGMEM = "0110110100100110010010110110";
  58. const char _9[] PROGMEM = "0110010100100110010010111110";
  59. const char _0[] PROGMEM = "0111110100000110000010111110";
  60. const char sc02[] PROGMEM = "0000001000000100000010000001"; // _
  61. const char sc09[] PROGMEM = "0010100001010000101000010100"; //[] PROGMEM =
  62.  
  63. const char A[] PROGMEM = "01111111001000100100010010000111111";
  64. const char B[] PROGMEM = "11111111001001100100110010010110110";
  65. const char C[] PROGMEM = "01111101000001100000110000010100010";
  66. const char D[] PROGMEM = "11111111000001100000110000010111110";
  67. const char E[] PROGMEM = "11111111001001100100110000011000001";
  68. const char F[] PROGMEM = "11111111001000100100010000001000000";
  69. const char G[] PROGMEM = "01111101000001100000110001010100110";
  70. const char H[] PROGMEM = "11111110001000000100000010001111111";
  71. const char J[] PROGMEM = "00001100000001000000100000011111110";
  72. const char K[] PROGMEM = "11111110001000001010001000101000001";
  73. const char L[] PROGMEM = "11111110000001000000100000010000001";
  74. const char M[] PROGMEM = "11111110100000001100001000001111111";
  75. const char N[] PROGMEM = "11111110010000000100000001001111111";
  76. const char O[] PROGMEM = "01111101000001100000110000010111110";
  77. const char P[] PROGMEM = "11111111001000100100010010000110000";
  78. const char Q[] PROGMEM = "01111101000001100010110000110111110";
  79. const char R[] PROGMEM = "11111111001000100110010010100110001";
  80. const char S[] PROGMEM = "01100101001001100100110010010100110";
  81. const char T[] PROGMEM = "10000001000000111111110000001000000";
  82. const char U[] PROGMEM = "11111100000001000000100000011111110";
  83. const char V[] PROGMEM = "11110000000110000000100001101111000";
  84. const char W[] PROGMEM = "11111000000011000110000000111111100";
  85. const char X[] PROGMEM = "11000110010100000100000101001100011";
  86. const char Y[] PROGMEM = "11000000010000000111100100001100000";
  87. const char Z[] PROGMEM = "10000111000101100100110100011100001";
  88. const char m[] PROGMEM = "00011110010000000111100100000001111";
  89. const char v[] PROGMEM = "00110000000110000000100001100011000";
  90. const char w[] PROGMEM = "00111100000001001111000000010011110";
  91. const char z[] PROGMEM = "00100010010011001010100110010010001";
  92. const char sc10[] PROGMEM = "00010000001000011111000010000001000"; // +
  93. const char sc11[] PROGMEM = "01101101001001011010100000100000101"; // &
  94. const char sc12[] PROGMEM = "01000001000000100110110010000110000"; // ?
  95. const char sc18[] PROGMEM = "00010100011111000101000111110001010"; // #
  96. const char sc22[] PROGMEM = "00101000111110101010110101011000001"; // €
  97. const char sc23[] PROGMEM = "00100100101010111111101010100100100"; // $
  98.  
  99.  
  100. const char sc14[] PROGMEM = "0100001101001001001000001000001001001001011000010"; // %
  101. const char sc15[] PROGMEM = "0000001000001000001000001000001000001000001000000"; // /
  102. const char sc16[] PROGMEM = "1000000010000000100000001000000010000000100000001"; // backslash
  103. const char sc17[] PROGMEM = "0011100010001010010011010101101110110001010111101"; // @
  104.  
  105.  
  106. const char* const charSet1[] PROGMEM = {i, l, sc07, sc08, sc13, sc20, sc24};
  107. const char* const charSet2[] PROGMEM = {sc05, sc06, sc00};
  108. const char* const charSet3[] PROGMEM = {I, f, j, sc01, sc03, sc04, sc19, sc21};
  109. const char* const charSet4[] PROGMEM = {a, b, c, d, e, g, h, k, n, o, p, q, r, s, t, u, x, y, _1, _2, _3, _4, _5, _6, _7, _8, _9, _0, sc02, sc09};
  110. const char* const charSet5[] PROGMEM = {A, B, C, D, E, F, G, H, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, m, v, w, z, sc10, sc11, sc12, sc18, sc22, sc23};
  111. const char* const charSet7[] PROGMEM = {sc17, sc14, sc15, sc16};
  112.  
  113. char msg[] = " L ______ ";
  114.  
  115. // Triggers
  116. const unsigned int triggers[7] = {
  117.   9, 8, 7, 6, 5, 4, 3
  118. };
  119.  
  120. // Commands
  121. const unsigned int startCommandPin = 2;
  122.  
  123. // DEBUG
  124. boolean debug = false; // -> false
  125.  
  126. // COMMANDS DEFAULT VALUES
  127. boolean startON = false;
  128.  
  129. //DRAWING INFO
  130.  
  131. int pointer = 0;
  132. boolean active = false; // -> false
  133.  
  134. const unsigned int triggerDelay = 250;
  135.  
  136. char buffer[60];
  137.  
  138. void setup() {
  139.   if (debug) Serial.begin(9600);
  140.   // Triggers
  141.   for (int i = 0; i < sizeof(triggers) / sizeof(int); i++) {
  142.     pinMode(triggers[i], OUTPUT);
  143.   }
  144.  
  145.   // Command buttons
  146.   pinMode(startCommandPin, INPUT_PULLUP);
  147. }
  148.  
  149.  
  150.  
  151.  
  152. void trigger(char t[]) {
  153.   for (int i = 7; i >= 0; i--) {
  154.     if (debug) Serial.print(t[i] == '1' ? "X " : "  ");
  155.     digitalWrite(triggers[i], t[i] == '1');
  156.     readStartButton(); // Stop ASAP
  157.         if(!active) {
  158.           return;
  159.         }
  160.   }
  161.   if (debug) Serial.println();
  162. }
  163.  
  164.  
  165. void loop() {
  166.   readStartButton();
  167.  
  168.   if (active) {
  169.  
  170.     printCharacter(msg[pointer]);
  171.     pointer += 1;
  172.  
  173.     if (pointer == sizeof(msg) -1) {
  174.       if (debug) Serial.println("FINISHED");
  175.       off();
  176.       pointer = 0;
  177.       active = false;
  178.     }
  179.   }
  180. }
  181.  
  182. void readStartButton() {
  183.   startON = !digitalRead(startCommandPin);
  184.   if (startON) {
  185.     if (debug) Serial.println("Start button ON");
  186.     if (active) { // STOP
  187.       if (debug) Serial.println("STOPPING");
  188.       active = false;
  189.       off();
  190.       delay(triggerDelay);
  191.     }
  192.     else { // START
  193.       if (debug) Serial.println("STARTING");
  194.       active  = true;
  195.       pointer = 0;
  196.       delay(triggerDelay);
  197.     }
  198.   }
  199. }
  200.  
  201. void off() {
  202.   for (int i = 0; i < sizeof(triggers) / sizeof(int); i++) {
  203.     digitalWrite(triggers[i], LOW);
  204.   }
  205. }
  206.  
  207. void printCharacter(char c) {
  208.   char t[7];
  209.  
  210.   if (characters1.indexOf(c) > -1) {
  211.     int index = (characters1).indexOf(c);
  212.     strcpy_P(buffer, (char*)pgm_read_word(&(charSet1[index])));
  213.     for (int x = 0; x < 7; x++) {
  214.       t[x] = (buffer[x]);
  215.     }
  216.     trigger(t);
  217.     delay(triggerDelay);
  218.   }
  219.   else if (characters2.indexOf(c) > -1) {
  220.     int index = (characters2).indexOf(c);
  221.     strcpy_P(buffer, (char*)pgm_read_word(&(charSet2[index])));
  222.     for (int i = 0; i < 2; i++) {
  223.       for (int x = 0; x < 7; x++) {
  224.         t[x] = (buffer[i * 7 + x]);
  225.       }
  226.       trigger(t);
  227.       delay(triggerDelay);
  228.     }
  229.   }
  230.  
  231.   else if (characters3.indexOf(c) > -1) {
  232.     int index = (characters3).indexOf(c);
  233.     strcpy_P(buffer, (char*)pgm_read_word(&(charSet3[index])));
  234.     for (int i = 0; i < 3; i++) {
  235.       for (int x = 0; x < 7; x++) {
  236.         t[x] = (buffer[i * 7 + x]);
  237.       }
  238.       trigger(t);
  239.       delay(triggerDelay);
  240.     }
  241.   }
  242.  
  243.   else if (characters4.indexOf(c) > -1) {
  244.     int index = (characters4).indexOf(c);
  245.     strcpy_P(buffer, (char*)pgm_read_word(&(charSet4[index])));
  246.     for (int i = 0; i < 4; i++) {
  247.       for (int x = 0; x < 7; x++) {
  248.         t[x] = (buffer[i * 7 + x]);
  249.       }
  250.       trigger(t);
  251.       delay(triggerDelay);
  252.     }
  253.   }
  254.  
  255.   else if (characters5.indexOf(c) > -1) {
  256.     int index = (characters5).indexOf(c);
  257.     strcpy_P(buffer, (char*)pgm_read_word(&(charSet5[index])));
  258.     //    Serial.println(buffer);
  259.     for (int i = 0; i < 5; i++) {
  260.       for (int x = 0; x < 7; x++) {
  261.         t[x] = (buffer[i * 7 + x]);
  262.       }
  263.       trigger(t);
  264.       delay(triggerDelay);
  265.     }
  266.   }
  267.  
  268.   else if (characters7.indexOf(c) > -1) {
  269.     int index = (characters7).indexOf(c);
  270.     strcpy_P(buffer, (char*)pgm_read_word(&(charSet7[index])));
  271.     for (int i = 0; i < 7; i++) {
  272.       for (int x = 0; x < 7; x++) {
  273.         t[x] = (buffer[i * 7 + x]);
  274.       }
  275.       trigger(t);
  276.       delay(triggerDelay);
  277.     }
  278.   }
  279.  
  280.     Serial.println(sizeof(buffer));
  281.  
  282.   off(); // Off between 2 letters
  283.   delay(triggerDelay * 2); //
  284. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top