標(biāo)題: STC12C5A60S2驅(qū)動LCD1602 [打印本頁]

作者: 229512035444    時(shí)間: 2018-5-23 23:38
標(biāo)題: STC12C5A60S2驅(qū)動LCD1602
/*********************************************************************************************************
** 工程功能 :串口通信程序
** 工程作者 :Blue Sky Teams——ZZL
** 工程版本 :V1.0
*********************************************************************************************************/
#include<STC12C5A60S2.h>
#include<LCD1602.h>
#include<ADC.h>
#define uchar        unsigned char
#define uint        unsigned int

#define FSCLK        11059200
//#define FSCLK        12000000

/*********************************************************************************************************
** 函數(shù)功能 :延時(shí)函數(shù)
** 函數(shù)說明 :利用軟件延時(shí),占用CPU,經(jīng)調(diào)試最小單位大約為1ms
** 入口參數(shù) :time:需要延時(shí)的時(shí)間,單位ms
** 出口參數(shù) :無
*********************************************************************************************************/
void Delay_ms(uint time)
{
        uint i,j;
        for(i = 0;i < time;i ++)
                for(j = 0;j < 930;j ++);
}
void main()
{
        float res0,res1;
        LCD_1602_Init(); //液晶顯示前進(jìn)行初始化

        ADC_Init(ADC_PORT0 | ADC_PORT1); //配置通道P1^0 ,P1^1 為AD采集口,如要配置其他其他口,直接用或運(yùn)算加進(jìn)初始化函數(shù)中
        Write_1602_String("ADC TEST",0xc0 + 0x04);

        while(1)
        {
                res0=GetADCResult(ADC_CH0);       
                Write_1602_String("U0=",0x80);
                Write_1602_Data(0x30 + (uint)res0%10);
                Write_1602_Data('.');
                Write_1602_Data(0x30 + (uint)(res0*10)%10);
                Write_1602_Data(0x30 + (uint)(res0*100)%10);
                Write_1602_Data('V');
                       
                res1=GetADCResult(ADC_CH1);       
                Write_1602_String("U1=",0x88);
                Write_1602_Data(0x30 + (uint)res1%10);
                Write_1602_Data('.');
                Write_1602_Data(0x30 + (uint)(res1*10)%10);
                Write_1602_Data(0x30 + (uint)(res1*100)%10);
                Write_1602_Data('V');
                Delay_ms(1000);       
        }       
}

/************************** (C) COPYRIGHT 2011 Blue Sky Teams *****END OF FILE*****************************/


作者: debug——1    時(shí)間: 2022-5-9 22:47
大佬 可以分享一下源碼嗎




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