Single chip electronic perpetual calendar with lunar calendar display

Publisher:清新心情Latest update time:2020-08-05 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Physical picture of the perpetual calendar:

The schematic diagram of the electronic perpetual calendar is as follows:


The simulation schematic diagram is as follows

The microcontroller source program is as follows:

#include

//#include"DS18B20_3.H"

#include

#include

#define uint unsigned int

#define uchar unsigned char

#define wd 1 //define whether there is temperature function =0 when there is no temperature, =1 when there is temperature



#define yh 0x80 //The initial position of the first line of LCD, because the first character address D7 of LCD1602 is always 1 (100000000=80)

#define er 0x80+0x40 //LCD second line initial position (because the first character position address of the second line is 0x40)


//Pin connection definition between LCD screen and C51 (display data line connected to C51 P0 port)

sbit en=P2^7;

sbit rw=P2^6; //If rw is grounded in hardware, you don't need to write this sentence and the following rw=0

sbit rs=P2^5;



//Definition of connection between the timing button and C51 pin


sbit set=P3^0; //Set key

sbit add=P3^1; //Add key

sbit dec=P3^2; //Decrement key

sbit seeNL_NZ=P3^3; //Check the lunar calendar/alarm clock


sbit DQ=P3^7; //

sbit buzzer=P2^0; //Buzzer, driven by transistor 8550, port low level rings


sbit led=P2^4; //LCD backlight switch

bit  led1=1;

bit ZDK=1,NZK=1; //Hourly time signal, alarm switch control bit =0, off, =1, on

bit zdkg=0,nzkg=0;

unsigned char temp_miao;

unsigned char bltime; //Backlight on time


//Pin connection definition between DS1302 clock chip and C51

sbit IO=P1^1;

sbit SCLK=P1^0;

sbit RST=P1^2;



uchar a,miao,shi,fen,ri,yue,nian,week,setn,temp;

uint flag;

//flag is used to read the temperature value in the header file and display the temperature value

bit c_moon;


uchar nz_shi=12,nz_fen=0,nz_miao=0,setNZn; //define alarm clock variables

uchar shangyimiao,bsn,temp_hour; //Record the last second

uchar T_NL_NZ; //Counter

bit timeron=0; //Alarm enable flag

bit baoshi=0; //Hourly time flag

bit p_r=0; // Normal year/rainy year =0 displays normal year, =1 displays rainy year

data uchar year_moon,month_moon,day_moon,week;




sbit ACC0=ACC^0;

sbit ACC7=ACC^7;

/************************************************************

ACC accumulator = A

ACC.0=E0H


ACC.0 is the 0th bit of ACC. Acc is bit addressable.


The accumulator ACC is an 8-bit storage unit used to store data. However, this storage unit has a special status.

It is a very critical unit in the microcontroller. Many operations must be performed through ACC.

A is often used to represent the accumulator. However, there are some exceptions, such as in the PUSH instruction, which must use the name ACC.

Generally speaking, A represents the contents of the accumulator, and ACC represents the address of the accumulator.

***************************************************************/




//********Gregorian calendar to lunar calendar table************************************

code uchar year_code[597]={

                    0x04,0xAe,0x53,    //1901 0

                    0x0A,0x57,0x48,    //1902 3

                    0x55,0x26,0xBd,    //1903 6

                    0x0d,0x26,0x50,    //1904 9

                    0x0d,0x95,0x44,    //1905 12

                    0x46,0xAA,0xB9,    //1906 15

                    0x05,0x6A,0x4d,    //1907 18

                    0x09,0xAd,0x42,    //1908 21

                    0x24,0xAe,0xB6,    //1909

                    0x04,0xAe,0x4A,    //1910

                    0x6A,0x4d,0xBe,    //1911

                    0x0A,0x4d,0x52,    //1912

                    0x0d,0x25,0x46,    //1913

                    0x5d,0x52,0xBA,    //1914

                    0x0B,0x54,0x4e,    //1915

                    0x0d,0x6A,0x43,    //1916

                    0x29,0x6d,0x37,    //1917

                    0x09,0x5B,0x4B,    //1918

                    0x74,0x9B,0xC1,    //1919

                    0x04,0x97,0x54,    //1920

                    0x0A,0x4B,0x48,    //1921

                    0x5B,0x25,0xBC,    //1922

                    0x06,0xA5,0x50,    //1923

                    0x06,0xd4,0x45,    //1924

                    0x4A,0xdA,0xB8,    //1925

                    0x02,0xB6,0x4d,    //1926

                    0x09,0x57,0x42,    //1927

                    0x24,0x97,0xB7,    //1928

                    0x04,0x97,0x4A,    //1929

                    0x66,0x4B,0x3e,    //1930

                    0x0d,0x4A,0x51,    //1931

                    0x0e,0xA5,0x46,    //1932

                    0x56,0xd4,0xBA,    //1933

                    0x05,0xAd,0x4e,    //1934

                    0x02,0xB6,0x44,    //1935

                    0x39,0x37,0x38,    //1936

                    0x09,0x2e,0x4B,    //1937

                    0x7C,0x96,0xBf,    //1938

                    0x0C,0x95,0x53,    //1939

                    0x0d,0x4A,0x48,    //1940

                    0x6d,0xA5,0x3B,    //1941

                    0x0B,0x55,0x4f,    //1942

                    0x05,0x6A,0x45,    //1943

                    0x4A,0xAd,0xB9,    //1944

                    0x02,0x5d,0x4d,    //1945

                    0x09,0x2d,0x42,    //1946

                    0x2C,0x95,0xB6,    //1947

                    0x0A,0x95,0x4A,    //1948

                    0x7B,0x4A,0xBd,    //1949

                    0x06,0xCA,0x51,    //1950

                    0x0B,0x55,0x46,    //1951

                    0x55,0x5A,0xBB,    //1952

                    0x04,0xdA,0x4e,    //1953

                    0x0A,0x5B,0x43,    //1954

                    0x35,0x2B,0xB8,    //1955

                    0x05,0x2B,0x4C,    //1956

                    0x8A,0x95,0x3f,    //1957

                    0x0e,0x95,0x52,    //1958

                    0x06,0xAA,0x48,    //1959

                    0x7A,0xd5,0x3C,    //1960

                    0x0A,0xB5,0x4f,    //1961

                    0x04,0xB6,0x45,    //1962

                    0x4A,0x57,0x39,    //1963

                    0x0A,0x57,0x4d,    //1964

                    0x05,0x26,0x42,    //1965

                    0x3e,0x93,0x35,    //1966

                    0x0d,0x95,0x49,    //1967

                    0x75,0xAA,0xBe,    //1968

                    0x05,0x6A,0x51,    //1969

                    0x09,0x6d,0x46,    //1970

                    0x54,0xAe,0xBB,    //1971

                    0x04,0xAd,0x4f,    //1972

                    0x0A,0x4d,0x43,    //1973

                    0x4d,0x26,0xB7,    //1974

                    0x0d,0x25,0x4B,    //1975

                    0x8d,0x52,0xBf,    //1976

                    0x0B,0x54,0x52,    //1977

                    0x0B,0x6A,0x47,    //1978

                    0x69,0x6d,0x3C,    //1979

                    0x09,0x5B,0x50,    //1980

                    0x04,0x9B,0x45,    //1981

                    0x4A,0x4B,0xB9,    //1982

                    0x0A,0x4B,0x4d,    //1983

                    0xAB,0x25,0xC2,    //1984

                    0x06,0xA5,0x54,    //1985

                    0x06,0xd4,0x49,    //1986

                    0x6A,0xdA,0x3d,    //1987

                    0x0A,0xB6,0x51,    //1988

                    0x09,0x37,0x46,    //1989

                    0x54,0x97,0xBB,    //1990

                    0x04,0x97,0x4f,    //1991

                    0x06,0x4B,0x44,    //1992

                    0x36,0xA5,0x37,    //1993

                    0x0e,0xA5,0x4A,    //1994

                    0x86,0xB2,0xBf,    //1995

                    0x05,0xAC,0x53,    //1996

                    0x0A,0xB6,0x47,    //1997

                    0x59,0x36,0xBC,    //1998

                    0x09,0x2e,0x50,    //1999 294

                    0x0C,0x96,0x45,    //2000 297

                    0x4d,0x4A,0xB8,    //2001

                    0x0d,0x4A,0x4C,    //2002

                    0x0d,0xA5,0x41,    //2003

                    0x25,0xAA,0xB6,    //2004

                    0x05,0x6A,0x49,    //2005

                    0x7A,0xAd,0xBd,    //2006

                    0x02,0x5d,0x52,    //2007

                    0x09,0x2d,0x47,    //2008

                    0x5C,0x95,0xBA,    //2009

                    0x0A,0x95,0x4e,    //2010

                    0x0B,0x4A,0x43,    //2011

                    0x4B,0x55,0x37,    //2012

                    0x0A,0xd5,0x4A,    //2013

                    0x95,0x5A,0xBf,    //2014

                    0x04,0xBA,0x53,    //2015

                    0x0A,0x5B,0x48,    //2016

                    0x65,0x2B,0xBC,    //2017

                    0x05,0x2B,0x50,    //2018

                    0x0A,0x93,0x45,    //2019

                    0x47,0x4A,0xB9,    //2020

                    0x06,0xAA,0x4C,    //2021

                    0x0A,0xd5,0x41,    //2022

                    0x24,0xdA,0xB6,    //2023

                    0x04,0xB6,0x4A,    //2024

                    0x69,0x57,0x3d,    //2025

                    0x0A,0x4e,0x51,    //2026

                    0x0d,0x26,0x46,    //2027

                    0x5e,0x93,0x3A,    //2028

                    0x0d,0x53,0x4d,    //2029

                    0x05,0xAA,0x43,    //2030

                    0x36,0xB5,0x37,    //2031

                    0x09,0x6d,0x4B,    //2032

                    0xB4,0xAe,0xBf,    //2033

                    0x04,0xAd,0x53,    //2034

                    0x0A,0x4d,0x48,    //2035

                    0x6d,0x25,0xBC,    //2036

                    0x0d,0x25,0x4f,    //2037

                    0x0d,0x52,0x44,    //2038

                    0x5d,0xAA,0x38,    //2039

                    0x0B,0x5A,0x4C,    //2040

                    0x05,0x6d,0x41,    //2041

                    0x24,0xAd,0xB6,    //2042

                    0x04,0x9B,0x4A,    //2043

                    0x7A,0x4B,0xBe,    //2044

                    0x0A,0x4B,0x51,    //2045

                    0x0A,0xA5,0x46,    //2046

                    0x5B,0x52,0xBA,    //2047

                    0x06,0xd2,0x4e,    //2048

                    0x0A,0xdA,0x42,    //2049

                    0x35,0x5B,0x37,    //2050

                    0x09,0x37,0x4B,    //2051

                    0x84,0x97,0xC1,    //2052

                    0x04,0x97,0x53,    //2053

                    0x06,0x4B,0x48,    //2054

                    0x66,0xA5,0x3C,    //2055

                    0x0e,0xA5,0x4f,    //2056

                    0x06,0xB2,0x44,    //2057

[1] [2] [3] [4] [5] [6] [7] [8]
Reference address:Single chip electronic perpetual calendar with lunar calendar display

Previous article:51 MCU Proteus simulation 320x240TFT color screen
Next article:Microcontroller breathing light program and waveform demonstration

Latest Microcontroller Articles
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号