Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. void Lcd_Port(char a){
  2. if (a & 1) D4=1;
  3. else D4=0;
  4.  
  5. if (a & 2) D5=1;
  6. else D5=0;
  7.  
  8. if (a & 4) D6=1;
  9. else D6=0;
  10.  
  11. if (a & 8) D7=1;
  12. else D7=0;
  13. }
  14. void Lcd_Cmd(char a){
  15. RS=0;
  16. Lcd_Port(a);
  17. EN=1;
  18. __delay_ms(20);
  19. EN=0;
  20. }
  21. void Lcd_Clear(){
  22. Lcd_Cmd(0);
  23. Lcd_Cmd(1);
  24. }
  25. void Lcd_Set_Cursor(char a,char b){
  26. char temp,y,z;
  27. if(a==1){
  28. temp=0x80+b-1;
  29. z=temp>>4;
  30. y=temp&0x0F;
  31. Lcd_Cmd(z);
  32. Lcd_Cmd(y);
  33. }
  34. else if(a==2){
  35. temp=0xC0+b-1;
  36. z=temp>>4;
  37. y=temp&0x0F;
  38. Lcd_Cmd(z);
  39. Lcd_Cmd(y);
  40. }
  41. }
  42. void Lcd_Write_Char(char a){
  43. char temp,y;
  44.  
  45. temp=a&0x0F;
  46. y=a&0xF0;
  47.  
  48. RS=1;
  49. Lcd_Port(y>>4);
  50. EN=1;
  51. __delay_us(40);
  52. EN=0;
  53. Lcd_Port(temp);
  54. EN=1;
  55. __delay_us(40);
  56. EN=0;
  57. }
  58. void Lcd_Write_String(char** a){
  59. int i;
  60. for(i=0;a[i]!='\0';i++){
  61. Lcd_Write_Char(a[i]);
  62. }
  63. }
  64. void Lcd_Init(){
  65. Lcd_Cmd(0x00);
  66. __delay_ms(20);
  67. Lcd_Cmd(0x03);
  68. __delay_ms(5);
  69. Lcd_Cmd(0x03);
  70. __delay_ms(11);
  71. Lcd_Cmd(0x03);
  72.  
  73. Lcd_Cmd(0x02);
  74. Lcd_Cmd(0x02);
  75.  
  76. Lcd_Cmd(0x08);
  77. Lcd_Cmd(0x00);
  78. Lcd_Cmd(0x0C);
  79. Lcd_Cmd(0x00);
  80. Lcd_Cmd(0x06);
  81. }
  82. void Lcd_Shift_Right(){
  83. Lcd_Cmd(0x01);
  84. Lcd_Cmd(0x0C);
  85. }
  86. void Lcd_Shift_Left(){
  87. Lcd_Cmd(0x01);
  88. Lcd_Cmd(0x08);
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement