Proteus simulation of perpetual calendar based on 51 MCU + LCD12864

Publisher:beta12Latest update time:2020-01-29 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The schematic diagram is as follows,

QQ picture 20190611101147.png

and part of the program is as follows.
QQ picture 20190611101259.png

The microcontroller source program is as follows:

#include

#include "DS18B20.h"

#include "DS1302.h"

#include "LCD12864.h"


char a;

sbit KEY1=P3^4;

sbit KEY2=P3^5;

sbit KEY3=P3^6;


bit flag=1; //Enter/Exit setting flag

uchar choose=0x01; //Switch flag

void delay10(void) //delay 10ms

{

        unsigned char i,j;

        for(i=0;i<255;i++)

        for(j=0;j<200;j++);

}

void delay5ms(void) //error 0us

{

    unsigned char a,b;

    for(b=19;b>0;b--)

        for(a=130;a>0;a--);

}


//When setting, the ds1302 register value cycles, such as the second register 59 plus one to 00

unsigned char conver(unsigned char a,unsigned char b,unsigned char c)

{        


        if((a&0x0f)==0x0a) a=a+6;

          if(a==b)  a=c;

        return a;  

}


void digplay() {


        //time

                ShowNumber16_32(2,0,TIME[2]>>4&0x03); //Time tens digit

                ShowNumber16_32(2,16, TIME[2]&0x0f); //Hour unit digit

                 ShowNumber16_32(2,48,TIME[1]>>4&0x07);//minutes and tens

                ShowNumber16_32(2,64, TIME[1]&0x0f); //Minutes and units

                ShowNumber16_32(2,96,TIME[0]>>4&0x07);//ten digits of seconds

                ShowNumber16_32(2,112, TIME[0]&0x0f); //seconds units

                

                

                //date

                ShowNumber(0,0,2);

                ShowNumber(0,8,0);

    ShowNumber(0,16,TIME[6]>>4&0x0f);

          ShowNumber(0,24, TIME[6]&0x0f);//年

                

          ShowNumber(0,40,TIME[4]>>4&0x01);

          ShowNumber(0,48, TIME[4]&0x0f);//月

                

                ShowNumber(0,64,TIME[3]>>4&0x03);

                ShowNumber(0,72, TIME[3]&0x0f);//日


          ShowChina(0,112,(TIME[5]&0x07)-1);//周

}

void wendu() {

                //temperature

                a=Read_Temperature(); //Read the temperature of DS18B20

                if(a<0) //Processing temperature positive and negative

                {        

                                a = (-1)*a; // complement

                                ShowNumber(6,88,11); //Thermometer icon—

                 }

                 else 

                { 

                                         ShowNumber(6,88,12); //Thermometer icon +

                 }

                        ShowNumber(6,96,a/10%10); //Show the median temperature

           

                ShowNumber(6,104,a%10); //Display low temperature


}


void digplaystart() {//Power on display

        fly i=0;

                ShowChina(2,64-16*1.5,19);

                ShowChina(2,64-16*0.5,20);

                ShowChina(2,64+16*0.5,21);

                ShowChina(2,64+16*1.5,22);

        for (i=0;i<10;i++) {

        ShowNumber(4,32+8*i,16);           

                delay5ms();

                delay5ms();

        }

        ClearScreen(0);//清屏

}


void main(void) 

{        

        flying i;

        InitLCD(); //Initialize LCD12864

        digplaystart();

        delay5ms();

        Ds1302Init(); //Ds1302 initializes and sets the default time

        a=Read_Temperature(); //Read the temperature of DS18B20

                        ShowNumber(0,32,11);//-

                ShowNumber(0,56,11);//-

                ShowChina(0,96,7);//Chinese Character Week

          ShowNumber16_32(2,32,10);//:

                ShowNumber16_32(2,80,10);//:

                ShowChina(6,112,8);//℃

        while(1)

        {

                wendu(); //Temperature display

                if(flag==1) 

                                Ds1302ReadTime();                

                                        //Read the time of DS1302

                else  

                Ds1302WriteTime();


if(KEY1==0) //Key 1--processing setting time and return

                {

                        delay10();

                        if(KEY1==1)

                        {

                                delay10();

                                flag=~flag;        

                                

                                if(flag==0) {

                                ShowChina(6,48,9);

                                ShowChina(6,0,16);

                                ShowChina(6,16,17);

                                ShowNumber(6,32,10);

                                }

                                if(flag==1) {

                                                for( i=0;i<8;i++) {

                                                        ShowNumber(6,8*i,15);

                                        }

                                }

                        }

                }


                if(KEY2==0) //Key 2--process the item to select the set time

                { 

                        delay10();

                        if(KEY2==1)

                        {

                                delay10();

                                choose++;

                                ShowChina(6,48,8+choose);

                                        if(choose==7)

                                        choose=0x00;

                        }        

                }


                if(KEY3==0) //Key 3--processing setting time and return

                { delay10();

                        if(KEY3==1)

                        {

                                delay10(); 

                                switch(choose)

                                {

                                        case 1:        TIME[6]++; TIME[6]=conver(TIME[6],0xa0,0x00);break;//年

                                        case 2:        TIME[5]++; TIME[5]=conver(TIME[5],0x08,0x01);break;//周

……………………



Reference address:Proteus simulation of perpetual calendar based on 51 MCU + LCD12864

Previous article:The ultimate program of 1602 calculator with single chip computer and clock
Next article:LD3320 routine based on 51 single chip microcomputer (password mode + IO port control program)

Recommended ReadingLatest update time:2024-11-16 15:29

LCD12864 driver
#include msp430g2553.h #include "lcd12864.h" #include "typedef.h"   #define cyCS BIT0 //P2.0, chip select signal #define cySID BIT1 //P2.1, serial data #define cyCLK BIT2 //P2.2, synchronous clock #define cyPORT P2OUT #define cyDDR P2DIR void Write_8bits(u8 W_bits) {       u8 i;       cyDDR |= cyCLK + cySID;   //设置输
[Microcontroller]
Single chip perpetual calendar (LCD12864, DS18B20, DS1302)
1. Introduction This circuit consists of AT89C51 minimum circuit board, LCD12864 display module, DS18B20 temperature module and DS1302 clock module. The main functions are: display real time and current temperature. 2. Operation Effect 3. Partial Code /*Want more projects private wo!!!*/ #include reg51.h #inclu
[Microcontroller]
Single chip perpetual calendar (LCD12864, DS18B20, DS1302)
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号