avr單片機proteus仿真第三課:單只數(shù)碼管
數(shù)碼管選7SEG-MPX1-CC,共陰極數(shù)碼管。也就是低電平選通(最右腳),數(shù)碼管左邊8只管腳,從左到右,由低到高,分別接PC0---PC7。
c程序如下:
#include
#include
#define int8u unsigned char
#define int16u unsigned int
const int8u seg_code[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
int main()
{
int8u i=0;
DDRC=0xff;
while(1)
{
PORTC=seg_code[i];
i=(i+1)%10; //i遞增到10的時候,重新設(shè)為0
_delay_ms(200);
}
}