Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.80 KB | None | 0 0
  1. char batteryFonts [10][5]={
  2. { 0, 1, 1, 2 }, // you see { this "0", 1, 1, 2 }, is a problem I think
  3. { 3, 1, 1, 2 },
  4. {etc}, }
  5. lcd.print( batteryFonts[0]); // this sentence does not work !!!
  6.  
  7. "char batteryFonts [10][5]={{ 4, 1, 1, 2 }, // 4 or what ever you want
  8. {etc},
  9. {etc}, }
  10.  
  11. lcd.print( batteryFonts[0]); // this sentence behind does work !!! but only with a row that starts not with a 0 WHY ??? can u tell me please ?
  12.  
  13. //This is a simple program that charges alkaline batteries
  14. //Copyleft
  15. #include <LiquidCrystal.h>
  16. // initialize the library with the numbers of the interface pins
  17. LiquidCrystal lcd(12, 13, 7, 4, 3, 2); // why pin 13 and not 12 ? because I love the led attached to it <3
  18.  
  19.  
  20. // the empty battery - end
  21. byte customLcdfont_A [8] = { // B stand for "Binary" and then the pixel ...
  22. B01111,
  23. B11000,
  24. B10101,
  25. B10100,
  26. B10100,
  27. B10100,
  28. B11000,
  29. B01111
  30.  
  31. // the empty battery body with fancy graphics enabled
  32.  
  33. };
  34. byte customLcdfont_B [8] = { // B stand for "Binary" and then the pixel ...
  35. B11111,
  36. B00000,
  37. B11001,
  38. B00000,
  39. B00000,
  40. B00000,
  41. B00000,
  42. B11111
  43. };
  44.  
  45.  
  46. // the empty battery + end
  47.  
  48. byte customLcdfont_C [8] = { // B stand for "Binary" and then the pixel ...
  49. B11100,
  50. B00100,
  51. B10111,
  52. B00101,
  53. B00111,
  54. B00111,
  55. B00100,
  56. B11100
  57. };
  58.  
  59.  
  60. // the full battery - end
  61.  
  62. byte customLcdfont_D [8] = { // B stand for "Binary" and then the pixel ...
  63. B1111,
  64. B11111,
  65. B10110,
  66. B10111,
  67. B10111,
  68. B10111,
  69. B11111,
  70. B1111
  71. };
  72.  
  73.  
  74. // the FULL battery + end
  75. byte customLcdfont_E [8] = { // B stand for "Binary" and then the pixel ...
  76. B11100,
  77. B11100,
  78. B01111,
  79. B11101,
  80. B11111,
  81. B11111,
  82. B11100,
  83. B11100
  84. };
  85.  
  86. // the full battery body
  87.  
  88. byte customLcdfont_F [8] = {
  89. B11111,
  90. B11111,
  91. B00110,
  92. B11111,
  93. B11111,
  94. B11111,
  95. B11111,
  96. B11111
  97. };
  98.  
  99. // the 1/3 battery body
  100.  
  101. byte customLcdfont_G [8] = {
  102. B11111,
  103. B11000,
  104. B00001,
  105. B11000,
  106. B11000,
  107. B11000,
  108. B11000,
  109. B11111
  110. };
  111. // the 2/3 battery body
  112.  
  113. byte customLcdfont_H [8] = {
  114. B11111,
  115. B11110,
  116. B00111,
  117. B11110,
  118. B11110,
  119. B11110,
  120. B11110,
  121. B11111
  122. };
  123.  
  124.  
  125.  
  126. /**************************************************************************/
  127. void setup() {
  128. int i = 0 ;
  129. // initialize serial communications at 9600 bps:
  130. lcd.createChar(0, customLcdfont_A);
  131. lcd.createChar(1, customLcdfont_B);
  132. lcd.createChar(2, customLcdfont_C);
  133. lcd.createChar(3, customLcdfont_D);
  134. lcd.createChar(4, customLcdfont_E);
  135. lcd.createChar(5, customLcdfont_F);
  136. lcd.createChar(6, customLcdfont_G);
  137. lcd.createChar(7, customLcdfont_H);
  138.  
  139. lcd.begin(16, 2);
  140.  
  141. // WATCH HERE IS THE PROBLEM !!!!
  142.  
  143. //the char table behind creates my different battery states as shown in the video ;)
  144.  
  145. char batteryFonts [10][5]={
  146.  
  147. { 0, 1, 1, 2 }, // this is an empty one f%*# this does not work !!!
  148. { 3, 1, 1, 2 },
  149. { 3, 6, 1, 2 },
  150. { 3, 7, 1, 2 },// this is a 50 % full charged battery !
  151.  
  152. { 3, 5, 1, 2 },
  153. { 3, 5, 6, 2 },
  154. { 3, 5, 7, 2 },
  155. { 3, 5, 5, 2 },
  156. { 3, 5, 5, 4 },// this is nice full one
  157. };
  158.  
  159.  
  160.  
  161. // this sentence behind does not work !!! but only with the raw [0]
  162.  
  163. lcd.print( batteryFonts[0]); // I F***ing want this to display the first raw !!!!
  164. lcd.setCursor(0,1 );
  165.  
  166. lcd.print(" not working ");
  167. lcd.setCursor(0,0 );
  168.  
  169.  
  170.  
  171.  
  172. delay(9300); // this make a short pause for us so that we can see the result
  173. lcd.setCursor(0,1 );
  174.  
  175. lcd.print(" working ");
  176. lcd.setCursor(0,0 );
  177. for (i=0; i=10 ; i+=1 ){
  178. delay(300);
  179.  
  180. lcd.setCursor(6,0 );
  181.  
  182. lcd.write(byte(0)); lcd.write(byte(1)); lcd.write(byte(1)); lcd.write(byte(2));
  183. delay(700); // batterry 0/8 empty aka discharged
  184.  
  185.  
  186. lcd.setCursor(6,0 );
  187. lcd.write(byte(3)); lcd.write(byte(1)); lcd.write(byte(1)); lcd.write(byte(2));
  188. delay(1000); //batterry 1 /8
  189.  
  190. lcd.setCursor(6,0 );
  191. lcd.write(byte(3)); lcd.write(byte(6)); lcd.write(byte(1)); lcd.write(byte(2));
  192. delay(1000);//batterry 2 /8
  193.  
  194. lcd.setCursor(6,0 );
  195. lcd.write(byte(3)); lcd.write(byte(7)); lcd.write(byte(1)); lcd.write(byte(2)); //batery 3 /8
  196.  
  197. delay(1000);
  198.  
  199. lcd.setCursor(6,0 );
  200. lcd.write(byte(3)); lcd.write(byte(5)); lcd.write(byte(1)); lcd.write(byte(2));
  201. delay(1000); //batery 4 /8
  202.  
  203. lcd.setCursor(6,0 );
  204. lcd.write(byte(3)); lcd.write(byte(5)); lcd.write(byte(6)); lcd.write(byte(2));
  205. delay(1000); //batery 5 /8
  206.  
  207. lcd.setCursor(6,0 );
  208. lcd.write(byte(3)); lcd.write(byte(5)); lcd.write(byte(7)); lcd.write(byte(2));
  209. delay(1000); //batery 6 /8
  210.  
  211. lcd.setCursor(6,0 );
  212. lcd.write(byte(3)); lcd.write(byte(5)); lcd.write(byte(5)); lcd.write(byte(2));
  213. delay(1000); //batery 7 /8
  214.  
  215. lcd.setCursor(6,0 );
  216. lcd.write(byte(3)); lcd.write(byte(5)); lcd.write(byte(5)); lcd.write(byte(4)); //batery 8 /8
  217.  
  218. delay(1000);
  219.  
  220. }
  221.  
  222.  
  223. lcd.setCursor(15, 1);
  224.  
  225. delay(115000);
  226.  
  227. }
  228.  
  229.  
  230.  
  231. /**************************************************************************/
  232. void loop() {
  233.  
  234. //This is not interesting here
  235. lcd.print(" ~ The end of the code ... thank you for reading ;) ~ ");
  236.  
  237. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement