1、#include #define uchar unsigned charvoid main (void); / 主函数void LED4_Display (void); / LED 显示void LED_OUT(uchar X); / LED 单字节串行移位函数unsigned char code LED_0F; / LED 字模表sbit DIO = P10; /串行数据输入sbit RCLK = P11; /时钟脉冲信号上升沿有效sbit SCLK = P12; /打入信号上升沿有效/-/ 全局变量uchar LED8; /用于 LED 的 8 位显示缓存,表示 LED0LED7/*/ 主
2、程序/void main (void) LED0=1;LED1=2;LED2=3;LED3=4;while(1)LED4_Display (); void LED4_Display (void)uchar i;/显示第 1 位i= LED_0FLED0;LED_OUT(i);LED_OUT(0x01);RCLK = 0;RCLK = 1;/显示第 2 位i = LED_0FLED1;LED_OUT(i);LED_OUT(0x02);RCLK = 0;RCLK = 1;/显示第 3 位i= LED_0FLED2;LED_OUT(i);LED_OUT(0x04);RCLK = 0;RCLK = 1;/显示第 4 位i= LED_0FLED3;LED_OUT(i);LED_OUT(0x08);RCLK = 0;RCLK = 1;void LED_OUT(uchar X)uchar i;for(i=8;i=1;i-)if (X else DIO=0;X=1;SCLK = 0;SCLK = 1;unsigned char code LED_0F = / 0 1 2 3 4 5 6 7 8 9 A b C d E F -0xC0,0xf9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x8C,0xBF,0xC6,0xA1,0x86,0xFF,0xbf;