欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 12864液晶顯示程序—適合我的51單片機開發(fā)板 [打印本頁]

作者: nius    時間: 2015-4-10 01:52
標題: 12864液晶顯示程序—適合我的51單片機開發(fā)板
#include <reg51.h>
/**********端口定義*************/
sbit RS = P1^0;
sbit RW = P1^1;
sbit E = P1^5;
#define  Date P0   //定義Date口為數(shù)據(jù)口P0
unsigned char code TV1[]={"這是薛羽豪的液晶"};
unsigned char code TV2[]={"哈哈哈哈哈哈哈哈"};
unsigned char code TV3[]={"056789asdfgh    "};
unsigned char code TV4[]={"!@#¥&*不是亂碼"};
void Delays(unsigned int x)                //延時子函數(shù)
{  unsigned int i,j;
   for(i=110;i>0;i--)
      for(j=x;j>0;j--);
}
void Write_Instruction(unsigned char Parameter) //寫指令(Write/Instruction)。。形參(Parameter)
{
RS=0;
RW=0;
E=0;
Date=Parameter;
Delays(5);
E=1;
Delays(5);
E=0;
}
void Write_Date(unsigned char Parameter) //寫數(shù)據(jù)(Write/Date)。。形參(Parameter)
{
RS=1;
RW=0;
E=0;
Date=Parameter;
Delays(5);
E=1;
Delays(5);
E=0;
}                                                                                   
void init_Lcd()                                                //液晶初始化(init/lcd)
{
Write_Instruction(0x01);
Delays(5);
Write_Instruction(0x0c);
Delays(5);
Write_Instruction(0x30);
Delays(5);
}
void Position_Lcd(unsigned char x,unsigned char y)        //進入點設(shè)定,,液晶顯示位置(Lcd/Position)
{
unsigned char  Position;
if(x==1)
        {x=0x80;}
else if(x==2)
        {x=0x90;}
else if(x==3)
        {x=0x88;}
else if(x==4)
        {x=0x98;}
Position=x+y;
Write_Instruction(Position);     //顯示地址
}
void main()
{
unsigned char Num1;
RS=0;
RW=0;
E=0;
init_Lcd();
Position_Lcd(1,0);
Num1=0;
while(TV1[Num1]!='\0')                //教材P176頁講述了TV1[Num1]!='\0'的意思特別是'\0'的意思("空"在儲存器中的存儲形式是"\0")
        {
         Write_Date(TV1[Num1]);
         Num1++;
        }
Position_Lcd(2,0);
Num1=0;
while(TV2[Num1]!='\0')
        {
         Write_Date(TV2[Num1]);
         Num1++;
        }
Position_Lcd(3,0);
Num1=0;
while(TV4[Num1]!='\0')
        {
         Write_Date(TV3[Num1]);
         Num1++;
        }
Position_Lcd(4,0);
Num1=0;
while(TV4[Num1]!='\0')
        {
         Write_Date(TV4[Num1]);
         Num1++;
        }
while(1);
}




作者: nius    時間: 2015-4-10 01:52
基于上一個程序改進后具有更快的刷新速度,程序刷新更快

  1. #include <reg51.h>
  2. /**********端口定義*************/
  3. sbit RS = P1^0;
  4. sbit RW = P1^1;
  5. sbit E = P1^5;
  6. #define  Date P0   //定義Date口為數(shù)據(jù)口P0
  7. unsigned char code TV1[]={"這是薛羽豪的液晶"};
  8. unsigned char code TV2[]={"哈哈哈哈哈哈哈哈"};
  9. unsigned char code TV3[]={"056789asdfgh    "};
  10. unsigned char code TV4[]={"!@#¥&*不是亂碼"};
  11. void Delays_Lcd(unsigned int x)        //延時子函數(shù)
  12. {  unsigned int i,j;
  13.    for(i=45;i>0;i--)
  14.       for(j=x;j>0;j--);
  15. }
  16. void Write_Instruction(unsigned char Parameter) //寫指令(Write/Instruction)。。形參(Parameter)
  17. {
  18. RS=0;
  19. RW=0;
  20. E=0;
  21. Date=Parameter;
  22. E=1;
  23. Delays_Lcd(0);
  24. E=0;
  25. }
  26. void Write_Date(unsigned char Parameter) //寫數(shù)據(jù)(Write/Date)。。形參(Parameter)
  27. {
  28. RS=1;
  29. RW=0;
  30. E=0;
  31. Date=Parameter;
  32. E=1;
  33. Delays_Lcd(0);
  34. E=0;
  35. }                  
  36. void init_Lcd()        //液晶初始化(init/lcd)
  37. {
  38. Write_Instruction(0x01);
  39. Write_Instruction(0x0c);
  40. Write_Instruction(0x30);
  41. }
  42. void Position_Lcd(unsigned char x,unsigned char y)        //進入點設(shè)定,,液晶顯示位置(Lcd/Position)
  43. {
  44. unsigned char  Position;
  45. if(x==1)
  46. {x=0x80;}
  47. else if(x==2)
  48. {x=0x90;}
  49. else if(x==3)
  50. {x=0x88;}
  51. else if(x==4)
  52. {x=0x98;}
  53. Position=x+y;
  54. Write_Instruction(Position);     //顯示地址
  55. }
  56. void main()
  57. {
  58. unsigned char Num1;
  59. RS=0;
  60. RW=0;
  61. E=0;
  62. init_Lcd();
  63. Position_Lcd(1,0);
  64. Num1=0;
  65. while(TV1[Num1]!='\0')        //教材P176頁講述了TV1[Num1]!='\0'的意思特別是'\0'的意思("空"在儲存器中的存儲形式是"\0")
  66. {
  67. Write_Date(TV1[Num1]);
  68. Num1++;
  69. }
  70. Position_Lcd(2,0);
  71. Num1=0;
  72. while(TV2[Num1]!='\0')
  73. {
  74. Write_Date(TV2[Num1]);
  75. Num1++;
  76. }
  77. Position_Lcd(3,0);
  78. Num1=0;
  79. while(TV4[Num1]!='\0')
  80. {
  81. Write_Date(TV3[Num1]);
  82. Num1++;
  83. }
  84. Position_Lcd(4,0);
  85. Num1=0;
  86. while(TV4[Num1]!='\0')
  87. {
  88. Write_Date(TV4[Num1]);
  89. Num1++;
  90. }
  91. while(1);
  92. }
復制代碼








歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1