#include <pIC.h>
__CONFIG(0x3B31);
const unsigned char tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//0-9--共阳极数码管
#define LED PORTB
#define SEG PORTC
unsigned char tmp[]={0,0,0,0,0,0,0,0};
void delay1ms(unsigned int x)
{
unsigned char i;
for(;x>0;x--)
for(i=0;i<165;i++);
}
void init()
{
TRISB=0x00;
PORTB=0xFF;
TRISC=0x00;
PORTC=0x00;
}
void display()
{
unsigned char i,SELE;
SELE=0x01;
for(i=0;i<8;i++)
{
SEG=SELE;
LED=tab[i];
delay1ms(5);
SELE<<=1;
LED=0xFF;
}
}
void main()
{
init();
while(1)
{
display();
}
}
8个数码管显示多个不同的字符
本文关键字:数码管 PIC单片机,单片机-工控设备 - PIC单片机
上一篇:PIC单片机捕捉模块的设计