Guest User

Untitled

a guest
May 26th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include "LCD.h"
  2. #include <htc.h>
  3. const char ScreenData[39] = {
  4. 0x41, //A 0
  5. 0x42, //B 1
  6. 0x43, //C 2
  7. 0x44, //D 3
  8. 0x45, //E 4
  9. 0x46, //F 5
  10. 0x47, //G 6
  11. 0x48, //H 7
  12. 0x49, //I 8
  13. 0x4A, //J 9
  14. 0x4B, //K 10
  15. 0x4C, //L 11 //CHARACTER DEFINITIONS!
  16. 0x4D, //M 12
  17. 0x4E, //N 13
  18. 0x4F, //O 14
  19. 0x50, //P 15
  20. 0x51, //Q 16
  21. 0x52, //R 17
  22. 0x53, //S 18
  23. 0x54, //T 19
  24. 0x55, //U 20
  25. 0x56, //V 21
  26. 0x57, //W 22
  27. 0x58, //X 23
  28. 0x59, //Y 24
  29. 0x5A, //Z 25
  30. 0x20, //SPACE 26
  31. 0x3A, //: 27
  32. 0x30, //0 28
  33. 0x31, //1 29
  34. 0x32, //2 30
  35. 0x33, //3 31
  36. 0x34, //4 32
  37. 0x35, //5 33
  38. 0x36, //6 34
  39. 0x37, //7 35
  40. 0x38, //8 36
  41. 0x39, //9 37
  42. 0x25 //% 38
  43. };
  44.  
  45. void Strobe_LCD()
  46. {
  47. E=1;
  48. _delay(4000);
  49. E=0;
  50. }
  51. /**********************************************************/
  52.  
  53. void Busy_Flag()
  54. {
  55. RW = 1; //read mode
  56. while(RB7); //Loop until finished
  57. RW=0; //default to write mode...
  58. }
  59.  
  60. void Write_LCD(unsigned char d,unsigned char x) //USE "Write_LCD(tabledata,1=cap0=lowercase);" (IF number Cap selection must equal 0!)
  61. {
  62. char z = 0x00;
  63. if(!x)
  64. {
  65. z=0x20;
  66. }
  67. TRISB=0x00;
  68. PORTB=d+z;
  69. Strobe_LCD();
  70. Busy_Flag();
  71. TRISB=0xFF;
  72. }
  73.  
  74. void AddressDisplay(unsigned char c)
  75. {
  76. Busy_Flag(); //check LCD ready
  77. RW = 0; //write mode
  78. RS=0; //command mode
  79. PORTB=c; //place data on data port
  80. TRISB = 0; //PORTB output
  81. Strobe_LCD();
  82. RS=1;
  83. TRISB = 0xFF; //PORTB input
  84. }
  85.  
  86. void lcd_init()
  87. {
  88. Write_LCD(0x38,1);
  89. Write_LCD(0x0C,1);
  90. Write_LCD(0x01,1);
  91. }
Add Comment
Please, Sign In to add comment