您现在的位置: 主页 > MCU > 单片机技术应用 > MSP430数码管的使用Ⅲ -
本文所属标签:
为本文创立个标签吧:

MSP430数码管的使用Ⅲ -

来源: 网络用户发布,如有版权联系网管删除 2018-09-07 

[导读]#include typedef unsigned char uchar; #define wei_h P5OUT |= BIT5 #define wei_l P5OUT &= BIT5 #define duan_l P6OUT &= ~BIT6 #define duan_h P6OUT |= BIT6 uchar table[16] = {0x3f,0x06,0x5b,0x4f,0x66,0x6

#include

本文引用地址: http://www.21ic.com/app/mcu/201807/780787.htm

typedef unsigned char uchar;

#define wei_h P5OUT |= BIT5

#define wei_l P5OUT &= BIT5

#define duan_l P6OUT &= ~BIT6

#define duan_h P6OUT |= BIT6

uchar table[16] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};

uchar num = 0;

void delay(int z)

{

int i,j;

for(i=z;i>0;i--)

for(j=112;j>0;j--);

}

void display(uchar dat)

{

P4OUT = table[num];

duan_h;

duan_l;

P4OUT = 0x00;

wei_h;

wei_l;

}

void main( void )

{

P1DIR = 0XFF;P1OUT = 0XFF;

P2DIR = 0XFF;P2OUT = 0XFF;

P3DIR = 0XFF;P3OUT = 0XFF;

P4DIR = 0XFF;P4OUT = 0XFF;

P5DIR = 0XFF;P5OUT = 0XFF;

P6DIR = 0XFF;P6OUT = 0XFF;

// Stop watchdog timer to prevent time out reset

WDTCTL = WDTPW + WDTHOLD;

while(1)

{

for(num=0;num<16;num++)

{

display(num);

delay(500);

}

}

}




              查看评论 回复



嵌入式交流网主页 > MCU > 单片机技术应用 > MSP430数码管的使用Ⅲ -
 

网站地图

围观()