|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 ldy7474 于 2017-1-9 00:09 编辑
前段时间无意中驱动了9.9的12864
这几天一直在研究
早期的单纯的显示汉子图片
是比较简单的运用了为了
让其更具有实用价值
今天用它来学习ADC
计算电压值
#include <reg51.h>
#include <intrins.h>
#include "12864Data.h"
#include "stc12c.h"
#include "lcd12864.h"
#include "ADC.h"
#define u8 unsigned char
#define u16 unsigned int
/*******萝莉控LCD引脚***************/
/*
sbit CS=P0^6;
sbit RST=P0^7;
sbit RS=P4^6;
sbit SDA=P4^5;
sbit SCK=P4^4;
*/
u16 CH1,CH2,CH3,CH4,CH5,CH6,CH7,V1;//
sbit LEDA=P2^5;//LCD背光
u16 adc;
u8 lcd[10];//显示缓存
void init (); //硬件初始化
void main(void)
{
init ();
LEDA=1;
delay_n_10us(100);//延时100ms等待稳定运行
InitLCD();
ClearScreen();
Display128x64(lcd_128x64);
lcd[6]=' ';
lcd[7]=' ';
lcd[8]=' ';
lcd[9]=' ';
while(1)
{
Display8x16(1,0,"L");
Display8x16(1,8,"D");
Display8x16(1,16,"Y");
Display5x7(1,52,"0");
Display5x7(1,60,"B");
Display5x7(1,68,"T");
Display8x16(2,28,"F");
Display8x16(2,36,"2");
Display8x16(2,44,"2");
Display8x16(2,74,"0");
Display8x16(2,82,"0");
Display8x16(2,90,":");
Display8x16(2,98,"0");
Display8x16(2,106,"0");
CH1=1+adcs(7);//*CH1代表7通道检测到的ADC值**/
//V1=V1*2;
CH1=CH1/204.8*10000;
lcd[0]= CH1/10000+48;
lcd[1]='.';
lcd[2]= CH1%10000/1000+48;
lcd[3]= CH1%1000/100+48;
lcd[4]= CH1%100/10+48;
Display5x7(6,82,lcd);
Display5x7(6,106,"V");
CH2=1+adcs(6);//*CH2代表6通道检测到的ADC值**/
CH2=CH2/204.8*10000;
lcd[0]= CH2/10000+48;
lcd[1]='.';
lcd[2]= CH2%10000/1000+48;
lcd[3]= CH2%1000/100+48;
lcd[4]= CH2%100/10+48;
Display5x7(5,82,lcd);
Display5x7(5,106,"V");
CH3=adcs(4);//*CH3代表4通道检测到的ADC值**/
lcd[0]= CH3/1000+48;
lcd[1]= CH3%1000/100+48;
lcd[2]= CH3%100/10+48;
lcd[3]= CH3%1000%10+48;
lcd[4]=' ';
Display5x7(5,30,lcd);
Display5x7(5,8,"C");
Display5x7(5,14,"H");
Display5x7(5,20,"3");
CH4=1+adcs(5);//*CH4代表5通道检测到的ADC值**/
CH4=CH4/204.8*10000;
lcd[0]= CH4/10000+48;
lcd[1]='.';
lcd[2]= CH4%10000/1000+48;
lcd[3]= CH4%1000/100+48;
lcd[4]= CH4%100/10+48;
Display5x7(6,30,lcd);
Display5x7(6,54,"V");
Display5x7(6,8,"C");
Display5x7(6,14,"H");
Display5x7(6,20,"4");
V1=1+adcs(8);//*V1代表8通道检测到的ADC值**/
V1=V1/204.8*10000;
lcd[0]= V1/10000+48;
lcd[1]='.';
lcd[2]= V1%10000/1000+48;
lcd[3]= V1%1000/100+48;
lcd[4]= V1%100/10+48;
Display5x7(1,82,lcd);
Display5x7(1,106,"V");
}
}
void init () //硬件初始化
{
LEDA=0;
P4SW=0x70; //允许P4 IO
P2M0=0x20; //推挽点亮背光
}
|
| |