日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁(yè) > 技術(shù)學(xué)院 > 熱搜器件
[導(dǎo)讀]LCD1602顯示簡(jiǎn)單時(shí)鐘程序

#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code  table[]=" 2009/04/29 THU";
uchar code table1[]="TIME:00-00-00";
sbit lcd_rs=P3^0;
sbit lcd_rw=P3^1;
sbit lcd_en=P3^2;
sbit k1=P1^0;
sbit k2=P1^1;
sbit k3=P1^2;
sbit k4=P1^3;
uchar count,k1num;
char shi,fen,miao;
void delay(uchar z)
{
 uint x,y;
 for(x=z;x>0;x--)
 for(y=110;y>0;y--);
}
void write_com(uchar com)
{
 lcd_rs=0;
 lcd_en=0;
 lcd_rw=0;
 P0=com;
 delay(5);
 lcd_en=1;
 delay(5);
 lcd_en=0;
}
void write_data(uchar date)
{
 lcd_rs=1;
 lcd_en=0;
 lcd_rw=0;
 P0=date;
 delay(5);
 lcd_en=1;
 delay(5);
 lcd_en=0;
}
void write_fsm(uchar add,uchar date)
{
 uchar shi,ge;
 shi=date/10;
 ge=date%10;
 write_com(0x80+0x40+add);
 write_data(0x30+shi);
 write_data(0x30+ge);
}
void jiaxian()
{
  if(k1num!=0)
   {
   if(k2==0)
   {
    delay(5);
    if(k2==0)
    {
     while(!k2);
     if(k1num==1)
     {
      miao++;
      if(miao==60)
   
       miao=0;
       write_fsm(11,miao);
       write_com(0x80+0x40+11);
    
     }
           if(k1num==2)
     {
      fen++;
      if(fen==60)
       fen=0;
       write_fsm(8,fen);
       write_com(0x80+0x40+8);
           }
        if(k1num==3)
        {
        shi++;
      if(shi==24)
       shi=0;
       write_fsm(5,shi);
       write_com(0x80+0x40+5);
  
     }
   }
  }
 }
}
void jianxian()
{
 if(k1num!=0)
 {
  if(k3==0)
  delay(5);
  if(k3==0)
  {
   while(!k3);
   if(k1num==1)
   {
    miao--;
    if(miao==-1)
     miao=59;
     write_fsm(11,miao);
     write_com(0x80+0x40+11);
   }
   if(k1num==2)
   {
    fen--;
    if(fen==-1)
     fen=59;
     write_fsm(8,fen);
     write_com(0x80+0x40+8);
   }
   if(k1num==3)
   {
    shi--;
    if(shi==-1)
     shi=23;
     write_fsm(5,shi);
     write_com(0x80+0x40+5);
   }
  }
 }
}
void kbscan()
{
 if(k1==0)
 {
  delay(5);
  if(k1==0)
  {
   while(!k1);
   k1num++;
   TR0=0;
   if(k1num==1)
   {
    write_com(0x80+0x40+11);
    write_com(0x0f); 
   }
   if(k1num==2)
   {
    write_com(0x80+0x40+8);
   }
   if(k1num==3)
   {
    write_com(0x80+0x40+5);
   }
   if(k1num==4)
   {
    k1num=0;
    write_com(0x0c);
    TR0=1;
   }
  }
 }
  jiaxian();
  jianxian();
  
}

void init()
{
 uchar num;
 lcd_rw=0;
 lcd_en=0;
 shi=0;
 fen=0;
 miao=0;
 write_com(0x38);
 write_com(0x0c);
 write_com(0x06);
 write_com(0x01);
 write_com(0x80);
 for(num=0;num<15;num++)
 {
  write_data(table[num]);
  delay(5);
 }
 write_com(0x80+0x40);
 for(num=0;num<13;num++)
 {
  write_data(table1[num]);
  delay(5);
 }
 TMOD=0x01;
 TH0=(65536-50000)/256;
 TL0=(65536-50000)%256;
 EA=1;
 ET0=1;
 TR0=1;
}
void main()
{
 init();
 while(1)
 {
  kbscan();
  if(count==18)
 {
  count=0;
  miao++;
  if(miao==60)
  {
   miao=0;
   fen++;
   if(fen==60)
   {
    fen=0;
    shi++;
    if(shi==24)
    {
     shi=0;
    }
    write_fsm(5,shi);
   }
   write_fsm(8,fen);
  }
  write_fsm(11,miao);
 }
 
 }
}
void time0() interrupt 1
{
 TH0=(65536-50000)/256;
 TL0=(65536-50000)%256;
 count++;
 
}

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

lcd1602液晶屏在很懂工業(yè)產(chǎn)品上都有應(yīng)用,LCD1602能夠能夠同時(shí)顯示32個(gè)字符,價(jià)格便宜,編程簡(jiǎn)單而且穩(wěn)定可靠。lcd1602液晶屏是一種圖形點(diǎn)陣顯示器,顯示原理簡(jiǎn)單易懂,都是液晶屏內(nèi)部的液晶材料變化而顯示不同的...

關(guān)鍵字: lcd1602 接線

  用戶所編的顯示程序,開始必須進(jìn)行初始化,否則模塊無(wú)法正常顯示,下面介紹兩種初始化方法:   1. 利用內(nèi)部復(fù)位電路進(jìn)行初始化   下面指令是在初始化過程中執(zhí)行的。  

關(guān)鍵字: lcd1602

51單片機(jī)——LCD1602

關(guān)鍵字: 51單片機(jī) lcd1602

一.接口LCD1602是很多單片機(jī)愛好者較早接觸的字符型液晶顯示器,它的主控芯片是HD44780或者其它兼容芯片。與此相仿的是LCD12864液晶顯示器,它是一種圖形點(diǎn)陣顯示器,能顯示的內(nèi)容比LCD1602要豐富得多,除...

關(guān)鍵字: lcd1602 單片機(jī) 顯示原理

程序要寫出自己的風(fēng)格********************************************************這是學(xué)習(xí) msp430g2553 單片機(jī)時(shí)寫的 1602 的程序****時(shí)間精確到us,...

關(guān)鍵字: lcd1602 msp430g2553

#include "lcd1602_driver.h"#include #include "typedef.h"#ifndef _LCD_1602_#define _LCD_160...

關(guān)鍵字: lcd1602 驅(qū)動(dòng)程序 4線數(shù)據(jù)傳輸

/這個(gè)程序已經(jīng)調(diào)試過了//下面調(diào)用實(shí)例////////////////////////////////////LCD1602讀寫頭文件//四線驅(qū)動(dòng)方式//////////////////////////////////#...

關(guān)鍵字: 51 lcd1602 四數(shù)據(jù)線驅(qū)動(dòng)

平臺(tái):stm32f302, 屏幕: LCD16021 #ifndef __LCD1602_H__2 #define __LCD1602_H__3 #include "stm32f30x.h"4 vo...

關(guān)鍵字: lcd1602 驅(qū)動(dòng) stm32f302

給?STC89C51?安一個(gè)?LCD1602?液晶顯示器。寫一段程序,使得?STC89C51?有計(jì)時(shí)、顯示功能。當(dāng)給?STC89C51?一個(gè)連續(xù)的高電平時(shí),單片機(jī)開始計(jì)時(shí),同時(shí)在顯示器上顯示計(jì)時(shí)的秒數(shù)

關(guān)鍵字: lcd1602 stc89c51 液晶顯示器

給?STC89C51?安一個(gè)?LCD1602?液晶顯示器。寫一段程序,使得?STC89C51?有計(jì)時(shí)、顯示功能。當(dāng)給?STC89C51?一個(gè)連續(xù)的高電平時(shí),單片機(jī)開始計(jì)時(shí),同時(shí)在顯示器上顯示計(jì)時(shí)的秒數(shù)

關(guān)鍵字: lcd1602 stc89c51 液晶顯示器
關(guān)閉