- #include <REGX52.H>
- void Delay(unsigned int xms)
- {
- unsigned char i, j;
- while(xms--)
- {
- i = 2;
- j = 239;
- do
- {
- while (--j);
- } while (--i);
- }
- }
- sbit RCK=P3^5; //RCLK
- sbit SCK=P3^6; //SRCLK
- sbit SER=P3^4; //SER
- #define MATTROX_LED_PORT P0
- /**
- * @brief 74HC595写入一个字节
- * @param Byte 要写入的字节
- * @retval 无
- */
- void _74HC595_WriteBytr(unsigned char Byte)
- {
- unsigned char i;
- for(i=0;i<8;i++)
- {
- SER=Byte&(0x80>>i);
- SCK=1;
- SCK=0;
- }
- RCK=1;
- RCK=0;
- }
- /**
- * @brief LED点阵屏显示一列数据
- * @param Column 要选择的列0~7
- * @param Data 选择的列显示的数据 1亮,0灭
- * @retval 无
- */
- void MatrixLED_ShowColmn(unsigned char Column,Data)
- {
- _74HC595_WriteBytr(Data);
- MATTROX_LED_PORT=~(0x80>>Column);
- Delay(1);
- MATTROX_LED_PORT=0xFF;
- }
- void main( )
- {
- SCK=0;
- RCK=0;
- while(1)
- {
- MatrixLED_ShowColmn(0,0x30);
- MatrixLED_ShowColmn(1,0x48);
- MatrixLED_ShowColmn(2,0x44);
- MatrixLED_ShowColmn(3,0x22);
- MatrixLED_ShowColmn(4,0x44);
- MatrixLED_ShowColmn(5,0x48);
- MatrixLED_ShowColmn(6,0x30);
-
- }
- }
复制代码 |