标题: LCD1602液晶屏静态与流动字母显示的单片机源码 [打印本页]

作者: 李脉123    时间: 2018-5-5 17:36
标题: LCD1602液晶屏静态与流动字母显示的单片机源码


单片机源程序如下:
  1. /*******************************************************************************
  2. --------------------------------------------------------------------------------
  3. * 实 验 名                 : LCD1602显示试验
  4. * 实验说明       : LCD1602第一行Pechin Science,第二行显示Welcome to the world
  5. *                * of MCU。并一直移动。
  6. * 连接方式       : 见连接图
  7. * 注    意                 :
  8. *******************************************************************************/
  9. #include<reg51.h>        
  10. #include"lcd.h"

  11. //--定义全局变量--//
  12. unsigned char PuZh[16] = " Pechin Science ";
  13. unsigned char CnCh[27] = "Welcome to the world of MCU";

  14. //--声明全局变量--//
  15. void Delay10ms(unsigned int c);   //误差 0us

  16. /*******************************************************************************
  17. * 函 数 名         : main
  18. * 函数功能                   : 主函数
  19. * 输    入         : 无
  20. * 输    出         : 无
  21. *******************************************************************************/
  22. void main(void)
  23. {
  24.         unsigned char i;

  25.         LcdInit();
  26.         
  27.         //--写第一行--//
  28.         for(i=0; i<16; i++)
  29.         {
  30.                 LcdWriteData(PuZh[i]);        
  31.         }

  32.         //--写第二行
  33.         LcdWriteCom(0xC0); //设置坐标在第二行
  34.         for(i=0; i<27; i++)
  35.         {
  36.                 LcdWriteData(CnCh[i]);
  37.         }

  38.         LcdWriteCom(0x07); //设置每写一次整屏右移
  39.         while(1)
  40.         {                        
  41.                 LcdWriteCom(0xC0); //设置坐标在第二行
  42.                 for(i=0; i<27; i++)
  43.                 {
  44.                         LcdWriteData(CnCh[i]);
  45.                         Delay10ms(50);
  46.                 }
  47.                
  48.         }                                
  49. }

  50. /*******************************************************************************
  51. * 函 数 名         : Delay10ms
  52. * 函数功能                   : 延时函数,延时10ms
  53. * 输    入         : 无
  54. * 输    出         : 无
  55. *******************************************************************************/

  56. void Delay10ms(unsigned int c)   //误差 0us
  57. {
  58. ……………………

  59. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
16、液晶屏LCD1602.zip (1.35 MB, 下载次数: 23)



作者: zc18421    时间: 2018-11-16 14:30
对于允许写入等一些指令搞不懂啊




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1