đã text ngon lành bác thử đoạn này xem sao ?
#include <REGX51.H>
#define START P3_0
#define ALE P3_1
#define A P3_2
#define B P3_3
#define C P3_4
#define dtlcd P2
#define adc P1
unsigned char code MA7D[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x90,0x8 0};
unsigned char nd;
void delay( unsigned int t)
{ while( t--); }
unsigned char docadc(unsigned char kenh)
{
A=kenh&(0x04);
B=kenh&(0x02);
C=kenh&(0x01);
START=ALE=1;
START=ALE=0;
delay(100);
return docadc;
}
void ht_nd()
{
nd=docadc(7);
delay(100);
P2=MA7D[nd/10]; P0_3=0; delay(100); P0_3=1;
P2=MA7D[nd%10]; P0_2=0; delay(100); P0_2=1;
}
void main()
{
while(1)
{ht_nd();
}
}
#define START P3_0
#define ALE P3_1
#define A P3_2
#define B P3_3
#define C P3_4
#define dtlcd P2
#define adc P1
unsigned char code MA7D[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x90,0x8 0};
unsigned char nd;
void delay( unsigned int t)
{ while( t--); }
unsigned char docadc(unsigned char kenh)
{
A=kenh&(0x04);
B=kenh&(0x02);
C=kenh&(0x01);
START=ALE=1;
START=ALE=0;
delay(100);
return docadc;
}
void ht_nd()
{
nd=docadc(7);
delay(100);
P2=MA7D[nd/10]; P0_3=0; delay(100); P0_3=1;
P2=MA7D[nd%10]; P0_2=0; delay(100); P0_2=1;
}
void main()
{
while(1)
{ht_nd();
}
}
Comment