pcf8591的按鍵代碼1、光敏2,外設(shè)電壓3,可調(diào)電壓,用S7按鈕控制
#include "reg52.h"
#include "iic.h"
#define TSMG 500
#define uchar unsigned char
#define uint unsigned int
#define PCF8591 0x90
uchar dat=0;
sbit S4=P3^3;
sbit P2_0=P2^0;
sbit P2_1=P2^1;
uchar D[32];
double dianya;
uchar code smg1[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x80,0xc0,0xc6,0x86,0x8e,0xbf,0x7f};
uchar code smg2[]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};
uint smg_vlot=0;
uchar adc_value=0;
float adc_vlot=0;
uchar mode=1;
uchar stat_smg=1;
uchar control;
uchar shi,ge,bai;
void Hc573(uchar channel,uchar dat)
{
P0=dat;
switch(channel)
{
case 0:
P2=P2&0x1f|0x00;
break;
case 4:
P2=P2&0x1f|0x80;
break;
case 5:
P2=P2&0x1f|0xa0;
break;
case 6:
P2=P2&0x1f|0xc0;
break;
case 7:
P2=P2&0x1f|0xe0;
break;
}
P2=P2&0x1f|0x00;
}
void delay(uint t)
{
while(t--);
}
void smgsm(uchar pos,uchar date)
{
Hc573(6,0x01<